WPF MVVM UserControl DataBinding in XAML Not Working
I've got a user control where the DataSource is an ObservableCollection<string>
.
If I set the DataSource of an instance of my user control via code it works
Chapters.DataSource = vm.ChapterList;
But trying to bind via ht xaml doesn't work
<b:ChapterStack x:Name="Chapters" DataSource="{Binding ChapterList}"></b:ChapterStack>
Other controls on the window开发者_JAVA技巧 are binding to the VM and displaying properly.
What do I have to do to get my usercontrol to bind via xaml?
thanks?
Make sure you defined the DataSource
property of your ChapterStack
control as a Dependency Property
, because otherwise, you won't be able to bind it.
精彩评论