Skip to main content
Notice removed Reward existing answer by juergen d
Bounty Ended with Sinatr's answer chosen by juergen d
Notice added Reward existing answer by juergen d
Bounty Started worth 50 reputation by juergen d
added 5 characters in body
Source Link
juergen d
  • 205.3k
  • 40
  • 304
  • 377

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; Thread.Sleep(2000);//do some searching here IsNotSearching = true; } 

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; Thread.Sleep(2000); IsNotSearching = true; } 

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; } 
deleted 104 characters in body
Source Link
juergen d
  • 205.3k
  • 40
  • 304
  • 377

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;   Thread.Sleep(2000);   IsNotSearching = true;  } 

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;   Thread.Sleep(2000);   IsNotSearching = true;  } 

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; Thread.Sleep(2000); IsNotSearching = true; } 
Source Link
juergen d
  • 205.3k
  • 40
  • 304
  • 377

C#: Disable button during search/calculation

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; Thread.Sleep(2000); IsNotSearching = true; }