title: How to enable a Button with its CanExecute method
body: <p>I am developing an application in WPF using MVVM, but I am stuck with the ICommand objects.</p>
  
  <p>I have a windows which contains some buttons, so, I bind them to their respective ICommand in XAML as below:</p>
  
  <pre><code>&lt;Button Command="{Binding DoSomethingCommand}" Content="Do Something" /&gt;
  </code></pre>
  
  <p>Then, In my view-model class I have written the following:</p>
  
  <pre><code>public class MyViewModel : ObservableObject
  {
  
      private bool isDoSomethingButtonEnabled = false;
      ....        
      public ICommand DoSomethingCommand
      {
          get;
          private set;
      }
      ....
      ....
      public MyViewModel()
      {
          DoSomethingCommand = new DelegateCommand&lt;String&gt;(this.OnDoSomething, this.CanDoSomething);
      }
  
      private void OnDoSomething(String arg)
      {
  
      }
  
      private bool CanDoSomething(String arg)
      {
          return isDoSomethingButtonEnabled;
      }
      ....
  }
  </code></pre>
  
  <p>So, Since I need that my button is not enabled the first time the window opens, I set my variable <code>isDoSomethingButtonEnabled</code> to <code>false</code>. And it works, the button is disabled at the beginning, but my problem is that when I change the variable <code>isDoSomethingButtonEnabled</code> to <code>true</code> at run time my button is still disabled.</p>
  
  <p>I have even done some tests after changing the variable <code>isDoSomethingButtonEnabled</code> to <code>true</code>, printing the result of <code>DoSomethingCommand.CanExecute()</code> and it shows "true"!</p>
  
  <p>so, what Should I do in order to enable my button??</p>
  
  <p>Thank you in advance</p>