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:
<Button Content="Search"
Command="{Binding StartSearchCommand}"
IsEnabled="{Binding IsNotSearching}" />
ViewModel:
private bool _isNotSearching;
public bool IsNotSearching
{
get { return _isNotSearching; }
set
{
_isNotSearching = value;
OnPropertyChanged("IsNotSearching");
}
}
private RelayCommand<object> _startSearchCommand;
public ICommand StartSearchCommand
{
get
{
if (_startSearchCommand == null)
_startSearchCommand = new RelayCommand<object>(p => ExecuteSearch());
return _startSearchCommand;
}
}
private void ExecuteSearch()
{
IsNotSearching = false;
//do some searching here
IsNotSearching = true;
}