I’m creating a usercontrol for lightswitch. This is basically a Silverlight usercontrol, which receive the businessObject on the “DataContext” property.
I can bind in the xaml side items without a problem, but on the code behind, I don’t know how to get informed when the dataContext has changed?
I need that for one special binding.
Thank you very much!
You can extend the control class (
UserControlin your case) and add a newDependencyPropertywrappingDataContextin order to exposePropertyChanged. See these three posts and this question. Alternatively, it may be the case that you don’t really need to listen toDataContextChanged, depending on what you’re trying to do, since it might be more appropriate to handle the changes in your model.Finally, if you have the patience and option, I hear that SL 5 exposes
DataContextChanged.