title: CanExecute and CanExecuteChanged, I must implement these with a RelayCommand?
body: <p>I am using MVVM-Light and i have my relay command working perfectly, I have just read that i should be implementing <code>CanExecuteChanged</code> and <code>CanExecute</code>. Although i am unable to find a good example.</p>
  
  <p>Does anyone have a good example of how to implement these.</p>
  
  <p>CanExecute needs to return False when it can't be executed but wouldn't just disbale the button ??</p>
  
  <p>When do i execute the <code>CanExecuteChanged</code>?</p>
  
  <p>Anyone have any good examples of when to use each one, my code works without but <a href="http://blog.galasoft.ch/archive/2009/09/26/using-relaycommands-in-silverlight-and-wpf.aspx" rel="noreferrer">this blog</a> post states that I should be implementing these items.</p>
  
  <p>I am a little confused, as I said I thought I would just bind the <code>Enabled</code> property or something to a property in the ViewModel so I can disable the button or a similar control?</p>
  
  <p>Any help in understanding would be really grateful.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>This is what i have now...  Its working but the button isn't physically DISABLED only the commmand doesn't run as i am returning false. I am calling CanExecuteMe in the constructor to force the RaiseCanExecuteChanged to run ... </p>
  
  <p>This runs in my construtor of my viewmodel</p>
  
  <pre><code>        this.Page2Command = new RelayCommand(() =&gt; this.GoToPage2(), () =&gt; CanExecuteMe);
  
          CanExecuteMe = false;
  </code></pre>
  
  <p>and here is the rest of my code, i took it from an example. </p>
  
  <pre><code>    private bool _canIncrement = true;
  
      public bool CanExecuteMe
      {
          get
          {
              return _canIncrement;
          }
  
          set
          {
              if (_canIncrement == value)
              {
                  return;
              }
  
              _canIncrement = value;
  
              // Update bindings, no broadcast
              //RaisePropertyChanged(CanIncrementPropertyName);
  
              Page2Command.RaiseCanExecuteChanged();
          }
      }
  
      public RelayCommand Page2Command
      {
          get;
          private set;
      }
  
      private object GoToPage2()
      {
          System.Windows.MessageBox.Show("Navigate to Page 2!");
          return null;
      }
  </code></pre>
  
  <p>And here is my XAML</p>
  
  <pre><code>  &lt;Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="31,77,0,0" x:Name="button1" VerticalAlignment="Top" Width="75" &gt;
              &lt;i:Interaction.Triggers&gt;
                  &lt;i:EventTrigger EventName="Click"&gt;
                      &lt;GalaSoft_MvvmLight_Command:EventToCommand Command="{Binding Page2Command, Mode=OneWay}"/&gt;
                  &lt;/i:EventTrigger&gt;
              &lt;/i:Interaction.Triggers&gt;
          &lt;/Button&gt;
  </code></pre>