What is the fastest way to update my DataContext binding to my WPF usercontrol so that it shows changes in the object it is bound to in the view?
+1
A:
The best option is to make your DataContext object implement INotifyPropertyChanged. Make any collections implement INotifyCollectionChanged (ie: use an ObservableCollection<T>
instead of List<T>
, etc).
If you do this, then the bindings will automatically stay up to date, with no effort on your part.
Reed Copsey
2010-03-24 16:02:55
when the data in my datacontext changes, it doesn't show in my view, however I have implemented INotifyPropertyChanged. I am using PRISM.
Tony
2010-03-26 13:04:16
Which data in your DataContext? If you're using collections, they must implement INot.CollectionChanged instead of propchanged. Otherwise, this should work, as it's the "standard" way of working in WPF.
Reed Copsey
2010-03-26 15:21:09
+1
A:
Binding an ObservableCollection (which implements a specific interface) with objects that implement INotifyPropertyChanged will immediately show changes to their values in the front end or backend whenever you make changes, as long as the binding modes are set to two way binding.
Brian
2010-03-24 16:04:48
A:
This question here appears to be very similar.
If you don't want to implement the INotifyProperty, you can use my answer and just set the datacontext again
Jacob Adams
2010-03-24 17:26:48