Binding to DependencyProperty doesn't work?

I think by setting the DataContext of your FirstView it breaks the data inheritance so your FirstView won't have access to the data (i.e. SelectedModel ) defined in your main viewmodel.

Up vote 1 down vote favorite share g+ share fb share tw.

I have 2 views (first view - custom user control, MainWindow view - main view with first custom control as a child). First view has TreeView and DependencyProperty SelectedModel which changes when user change selection in TreeView. Main window view also has label with binding to SelectedModel property of MainWindowModel.

Label doesn't updates. Wpf binding mvvm dependency-properties link|improve this question edited Apr 2 at 3:18 asked Apr 2 at 0:49Dmitriy1518 95% accept rate.

Pls use edit to add your code to your question – blindmeis Apr 2 at 8:30.

I think by setting the DataContext of your FirstView, it breaks the data inheritance so your FirstView won't have access to the data (i.e. SelectedModel) defined in your main viewmodel. Try commenting out public FirstView() { InitializeComponent(); //this.

DataContext = _viewModel; } and see if it works.

I comment "this. DataContext = _viewModel;", remove FirstViewModel and add additional DependencyProperty VendorsSourceProperty to FirstView. I also set .

And now tree view doesn load any items :( – Dmitriy Apr 2 at 1:56 VendorsSource should just be a collection of vendors and should be set in your main view model. It doesn't need to be a dependency property. – Xin Apr 2 at 1:59 I place ObservableCollection Vendors to MainWindowViewModel and edit MainWindowView to .

In VendorView I add DependencyProperty VendorsSourceProperty and set . How can I bind treeview in VendorView to collection in MainWindowViewModel without VendorsSourceProperty? – Dmitriy Apr 2 at 2:04 If I set it's will load items, but why child view must known collection name of parent view?

– Dmitriy Apr 2 at 2:09 I got you now... What is the type of VendorsSourceProperty? – Xin Apr 2 at 2:10.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions