I'm using ObservableProperty attribute from MVVM toolkit, for the string SearchString which has binding for the TextBlock.Text property. I want to start command once change in TextBlock was made so I have set the attribute for change notification.
ViewModel part:
[ObservableProperty]
[NotifyCanExecuteChangedFor(nameof(UpdateSearchCommand))]
string searchString = string.Empty;
[RelayCommand]
async Task UpdateSearch()
{
MessageBox.Show("Hello");
await Task.CompletedTask;
}
View part:
<TextBox x:Name="txtSearch" Width="200" Height="30"
Grid.Row="0" Grid.Column="0"
HorizontalAlignment="Right"
VerticalAlignment="Center"
BorderThickness="0"
Margin="0 0 10 0"
Padding="0 5 0 0"
Text="{Binding SearchString}">
<TextBox.ToolTip>
<ToolTip Content="{Binding Loc[SearchNameOrDesc_TT]}"/>
</TextBox.ToolTip>
I don't know why, but when I write something into textBlock, the command does not trigger.
Does anybody has some experience with such as behavior?
I'll be glad for any advice or even a hint.
Thanks