There is only one property implementation in a user control that supports binding on the consumption page. This is a dependency property. The implementation is quite simple, but you must also include the changed event to interact directly with the user interface, since the dependency property is a static property of the control. Like this:
public string TextBoxText { get { return (string)GetValue(TextBoxTextProperty); } set { SetValue(TextBoxTextProperty, value); } } public static readonly DependencyProperty TextBoxTextProperty = DependencyProperty.Register("TextBoxText", typeof(string), typeof(MyUserControl), new PropertyMetadata(string.Empty, OnTextBoxTextPropertyChanged)); private static void OnTextBoxTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { (d as MyUserControl).MyTextBox.Text = e.NewValue.ToString(); }
I admit that this is not too obvious. But, hopefully, now that you know this, it will save you hours of searching and trying to find out. Again, you can only bind to the dependency property of the user control. And you can only set user interface values ββfrom a static stream with a modified event.
Good luck
source share