title: RelayCommand CanExecute behavior not working
body: <p>I'm having trouble getting the <code>RelayCommand</code> to enable/disable the attached control properly. </p>
  
  <p>I've got an <code>EventToCommand</code> element attached to a button. The command is databound to the ViewModel. Initially, the button is disabled (expected behavior), but I cannot seem to get the <code>CanExecute</code> logic to check it's value. When <code>CurrentConfigFile</code> is set and exists, the button should be enabled. I've executed code and checked the file's value in debug to make sure it's set, but the control is still disabled. I've tried <code>CommandManager.InvalidateRequerySuggested()</code> and <code>command.RaiseCanExecuteChanged()</code>, but it will not enable. </p>
  
  <p>I've wondered if lambdas don't work correctly for the <code>CanExecute</code> behavior (even though the examples use them) or that the <code>CanExecute</code> behavior needs to be databound to another element.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>// The FileInfo being checked for existence before the button should be enabled
  public const string CurrentConfigFilePN = "CurrentConfigFile";
  public FileInfo CurrentConfigFile
  {
      get
      {
          return _currentConfigFile;
      }
  
      set
      {
          if (_currentConfigFile == value)
          {
              return;
          }
  
          var oldValue = _currentConfigFile;
          _currentConfigFile = value;
  
          // Update bindings, no broadcast
          RaisePropertyChanged(CurrentConfigFilePN);
      }
  }
  
  public MainViewModel()
  {
      // snip //
  
      SaveCommand = new RelayCommand(SaveConfiguration, 
          () =&gt; CurrentConfigFile != null &amp;&amp; CurrentConfigFile.Exists);
      }
  
  private void SaveConfiguration()
  {
  
      // export model information to xml document
      ExportXMLConfiguration(CurrentConfigFile);
  
  }
  </code></pre>
  
  <p>and markup </p>
  
  <pre><code>&lt;Button x:Name="SaveButton" Content="Save" Width="75" Margin="20,5"&gt;
      &lt;i:Interaction.Triggers&gt;
          &lt;i:EventTrigger EventName="Click"&gt;
              &lt;GalaSoft:EventToCommand x:Name="SaveETC" 
                  Command="{Binding SaveCommand}" 
                  MustToggleIsEnabledValue="true" /&gt;
          &lt;/i:EventTrigger&gt;
      &lt;/i:Interaction.Triggers&gt;
  &lt;/Button&gt;
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>As per Isak Savo's suggestion, I bound the <code>RelayCommand</code> directly to the button with </p>
  
  <pre><code>&lt;Button x:Name="SaveButton" Content="Save" Width="75" Margin="20,5" 
  Command="{Binding SaveCommand}"/&gt;
  </code></pre>
  
  <p>and it started disabled and correctly enabled when the <code>FileInfo</code> was set. Guess I should remember not to fix what isn't broken! </p>