I have a textbox and a button I want to clear the contents of textbox on button click. I am using MVVM prism.
My XAML is
<TextBox Grid.Row="0" Text="{Binding
Path=TextProperty,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}" Name="txtUserEntry2"/>
<Button Content="Select"
Command="{Binding Path=MyCommand}" />
and In my View Model
public string TextProperty
{
get
{
return selectedText;
}
set
{
selectedText = value;
SetProperty(ref selectedText, value);
}
}
//////.........
private void MyCommandExecuted(object obj)
{
TextProperty= string.Empty;
MessageBox.Show("Command Executed");
}
But it does not clear the textbox. What am I missing ?