Is it possible to set the DataContext property of a usercontrol after the user control has been loaded, and force the usercontrol to rebind?
From stackoverflow
-
I'm pretty sure that if you just set the datacontext again, it will rebind
-
Setting the DataContext property should cause the rebind.
-
If you need to do extra work when the DataContext changes you can use a custom DependencyProperty and bind it to the DataContext property. Use the DependencyPropertyChangedEventHandler to know when the DP changed.
For a more complete explanation see my blog post at http://msmvps.com/blogs/theproblemsolver/archive/2008/12/29/how-to-know-when-the-datacontext-changed-in-your-control.aspx.
0 comments:
Post a Comment