Pass wpf dependency property to usercontrol for child control
I have a custom MyControl: UserControl with a dependency property
string Text
Inside MyControl in XAML I have a TextBox.
I want to bind the Text dependency property of MyControl to the text dependency property of the TextBox .
What's the best way to do this? Can I declare the MyControl dependency property to go to the child dependency property?
+3
source to share
2 answers
My answer here details a good example of how you can do this. Essentially, your controls are bound to properties in viewmodels, and the child view model has a dependency property that allows you to bind the child control and can output a value to the child view model. The example is in Silverlight, but the implementation is the same for WPF.
+1
source to share