I have a search dialog where I want to disable the search button during the search. This is the current code but the button does not get deactivated
View:
You could try command can execute to disable the command without adding IsEnabled
property
private RelayCommand _startSearchCommand;
public RelayCommand StartSearchCommand
{
get
{
return _startSearchCommand??
(_startSearchCommand=
//Added can execute command , only execute if system is not busy at the moment.
new RelayCommand(async () => await OnExecuteSearch(), () => !IsBusy));
}
}
Command handler
internal async Task OnExecuteSearch()
{
IsBusy = true;
//Execute your action
//and finally
IsBusy = false;
}
Xaml
The canexecute
in the Relay Command will control the IsEnabled
property for you.