title: How to bind button to control
body: <p>I am new to WPF. I have a button on my mainwindow</p>
  
  <pre><code>&lt;Button Grid.Row="1" x:Name="btnSelect" Command="{Binding SaveCommand}"   
        Content="Select" 
       IsEnabled="{Binding CanExec,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
  </code></pre>
  
  <p>and in myViewModel</p>
  
  <pre><code>    private bool _canExecute;
      private ICommand saveCommand;
      public MainWindow()
      {
          InitializeComponent();
          DataContext = this;
            CreateSaveCommand();
  
      }
     private void CreateSaveCommand()
      {
          this.saveCommand = new DelegateCommand&lt;object&gt;(this.OnSaveClick,    this.CanSaveExecute);
      }
      public ICommand SaveCommand
      {
          get { return this.saveCommand; }
      }
      private void OnSaveClick(object arg)
      {
  
  
      }
      private bool CanSaveExecute(object arg)
      {
          return CanExec;
  
      }
  
      public bool CanExec
      {
  
          get { return _canExecute; }
          set { _canExecute = value; OnPropertyChanged("CanExec"); }
      }
  
      public event PropertyChangedEventHandler PropertyChanged;
      private void OnPropertyChanged(string p)
      {
          if (PropertyChanged == null)
              PropertyChanged(this, new PropertyChangedEventArgs(p));
      }
  </code></pre>
  
  <p>But the button always remain disabled..What am I missing ??</p>