I have Textbox and my User Control, how can i Binding Textbox property Text to my Property Message in UserControl?
XAML:
<TextBox Name="txtMessages"/>
<myControl:MyAppBar x:Name="appBar" Message="{Binding ElementName=txtMessages, Path=Text, Mode=TwoWay}" Grid.Row="3"/>
And my Property:
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
private string message;
public string Message
{
get
{
return message;
}
set
{
message = value;
RaisePropertyChanged("Message");
}
}
But it's don't work for me. I get error as:
The text associated with this error code could not be found.
Also i try this: i try tihs:
public static readonly DependencyProperty UserControlTextProperty = DependencyProperty.Register(
"Message",
typeof(int),
typeof(ImageList),
new PropertyMetadata(0, new PropertyChangedCallback(MyControl.MyAppBar.OnUserControlTextPropertyChanged))
);
public string Message
{
get { return (string)GetValue(UserControlTextProperty); }
set { SetValue(UserControlTextProperty, value); }
}
but unsver: "The text associated with this error code could not be found."