Hi,
I have a textbox that is bound to a property in the ViewModel. When I run it for the first time and update the property, I see it updated in the UI. But after that, it doesn't get updated at all. I've seen similar posts and I'm doing all the things they've mentioned. I'm stumped. Here's my code:
<TextBox x:Name="SampleText" Height="23" TextWrapping="Wrap" Margin="0,0,0,3" MinWidth="450" Grid.Column="2" Grid.Row="2" Grid.ColumnSpan="2" Text="{Binding Sample,UpdateSourceTrigger=PropertyChanged,Mode=TwoWay}"/>
<Button x:Name="ClickHere" Content="UpdateText" Width="40" Height="Auto" Command="{Binding ButtonClickCommand}" CommandParameter="{Binding ElementName=UserControlView">
private string sample;
public string Sample
{
get { return sample; }
set
{
if (value != sample)
{
sample= value;
OnPropertyChanged("Sample");
}
}
}
public ButtonClickCommand
{
Sample = "Text Updated";
}
When I run this code for the first time and click the button, the TextBox gets updated in the UI. But when I close the window and open it again, while the code is running, and click the button, the TextBox doesn't get updated.
Help please!