title: Enable/Disable WPF button based on ListView population
body: <p>I have defined a button in my <code>View</code> (<strong>AXML</strong>) with the following code:</p>
  
  <pre><code>&lt;Button Content="Fetch Data" Command="{Binding readInventoryFilesCommand}" CommandParameter="{Binding Path=Text, ElementName=browseFolderTextBox}" Name="button1" /&gt;
  </code></pre>
  
  <p>The button works as expected but I would like it to be enabled/disabled if a <code>ListView</code> has been populated with elements.</p>
  
  <ul>
  <li>If no elements in the listView --> Button <code>IsEnabled</code> set to <code>false</code></li>
  <li>If there are elements in the listView --> Button <code>IsEnabled</code> set to <code>true</code></li>
  </ul>
  
  <p>I tried to play around with <code>IsEnabled="{Binding ...</code> but I am not getting <code>code completion</code> in <code>Visual Studio C# Express</code> and it is hard to guess the alternatives.</p>
  
  <p>The command looks like this:</p>
  
  <pre><code>internal class ReadInventoryFilesCommand : ICommand
  {
      public ReadInventoryFilesCommand(ResourceViewModel viewModel)
      {
          _viewModel = viewModel;
      }
  
      private ResourceViewModel _viewModel;
  
      #region ICommand Members
  
      event EventHandler ICommand.CanExecuteChanged
      {
          add
          {
              CommandManager.RequerySuggested += value;
          }
          remove
          {
              CommandManager.RequerySuggested -= value;
          }
      }
  
      bool ICommand.CanExecute(object parameter)
      {
          return _viewModel.CanUpdate;
      }
  
      void ICommand.Execute(object parameter)
      {
          _viewModel.ReadInventroyFiles(parameter.ToString());
      }
      #endregion
  }
  </code></pre>
  
  <p><strong><em>EDIT</em></strong>
  This is the current code after Bobs advice:</p>
  
  <pre><code>internal class ReadInventoryFilesCommand : ICommand
      {
          public ReadInventoryFilesCommand(ResourceViewModel viewModel)
          {
              _viewModel = viewModel;
              _viewModel.PropertyChanged+= (s,e) =&gt; { 
                  if (e.PropertyName == "CanUpdate") RaiseCanExecuteChanged();
              };
          }
  
          private ResourceViewModel _viewModel;
  
          event EventHandler ICommand.CanExecuteChanged;
  
          bool ICommand.CanExecute(object parameter)
          {
              return _viewModel.CanUpdate;
          }
  
          void ICommand.Execute(object parameter)
          {
              _viewModel.ReadInventroyFiles(parameter.ToString());
          }
  
          void RaiseCanExecuteChanged() {
              var handler = this.CanExecuteChanged;
              if (handler != null) handler(this,EventArgs.Empty);
          }
      }
  </code></pre>
  
  <p>It generates the following errors:</p>
  
  <pre><code>An explicit interface implementation of an event must use event accessor syntax 
  </code></pre>