I would like my user control to modify the text of a TextBlock in its parent. The parent control should be able to bind the TextBlock to a property in the user control.
The TextBlock is currently not binding.
Here is how I am currently trying to do this:
Parent Control:
<localcontrols:MyControl TextName="{Binding texttest}"/> <TextBlock x:Name="texttest"/> User Control Code:
public static readonly DependencyProperty TextNameProperty = DependencyProperty.Register("TextName", typeof(TextBlock), typeof(MyControl), new PropertyMetadata((TextBlock)null, MyControl.TextNameValueChanged)); public TextBlock TextName { get { return (TextBlock)this.GetValue(MyControl.TextNameProperty); } set { this.SetValue(MyControl.TextNameProperty, value); } } private static void TextNameValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { }