title: C# WPF => commands doesn't work though binding and using ICommand. Compiler doesn't throw any exception
body: <p>!!! SOLVED, THANK YOU VERY MUCH !!!</p>
  <p>I'm writing my first MVVM application (in WPF C#). Because of that, I want to use commands instead &quot;Click&quot; event defined in a view. The command, which I want to induce is really simple, it should to create and open a view.</p>
  <ol>
  <li>I have written RelayCommand class which inherits ICommand interface.</li>
  </ol>
  <pre><code>      internal class RelayCommand : ICommand
        {
            readonly Action&lt;object&gt; _execute;
            readonly Predicate&lt;object&gt; _canExecute;
      
            public RelayCommand(Action&lt;object&gt; execute, Predicate&lt;object&gt; canExecute)
            {
                _execute = execute ?? throw new ArgumentNullException(&quot;execute&quot;);
                _canExecute = canExecute;
            }
      
            public bool CanExecute(object parameter)
            {
                return _canExecute == null || _canExecute(parameter);
            }
      
            public event EventHandler CanExecuteChanged
            {
                add
                {
                    CommandManager.RequerySuggested += value;
                }
                remove
                {
                    CommandManager.RequerySuggested -= value;
                }
            }
      
            public void Execute(object parameter)
            {
                _execute(parameter);
            }
        }
  </code></pre>
  <ol start="2">
  <li><p>I write a method changing value of the field, which represent a view.</p>
  <pre><code>private bool openSoundsWindow;
  private bool openChordsWindow;
  
  public bool OpenSoundsWindow
  {
     get { return openSoundsWindow; }
     set { openSoundsWindow = value; }
  }
  
  public bool OpenChordsWindow
  { 
     get { return openChordsWindow; }
     set { openChordsWindow = value; }
  }
  
  public void OpenSounds()
  {
     openSoundsWindow = true;
  }
  
  public void OpenChords()
  {
     OpenChordsWindow = true;
  }
  </code></pre>
  </li>
  <li><p>I wrote in view model class commands by RelayCommand and OnPropertyChanged event. View model class inherits INotifyPropertyChanged.</p>
  </li>
  </ol>
  <pre><code>private MainModel model = new MainModel();
   
   public event PropertyChangedEventHandler PropertyChanged;
   
    private void OnPropertyChanged([CallerMemberName] string propertyName = null)
    {
         PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
     }
   
   public bool OpenSoundsWindow
   {
         get { return model.OpenSoundsWindow; }
   
         set
         {
             model.OpenSoundsWindow = value;
             OnPropertyChanged(nameof(OpenSoundsWindow));
         }
    }
   
  private ICommand openSounds = null;
   
   public ICommand OpenSounds
   {
         get
         {
              if (openSounds == null)
              {
                   openChords = new RelayCommand(
                    (object o) =&gt;
                     {
                         model.OpenSounds();
                         OnPropertyChanged(nameof(OpenSoundsWindow));
                         var newSoundsWindow = new Sounds();
                         newSoundsWindow.Show();
                     },
                     (object o) =&gt;
                     {
                         return model.OpenSoundsWindow != null;
                    });
              }
   
               return openSounds;
           }
    }
  </code></pre>
  <ol start="4">
  <li>I created instance of view model in view's xaml code.</li>
  </ol>
  <pre><code>xmlns:vm=&quot;clr-namespace:HearingTeacher.ViewModels&quot; 
          d:DataContext=&quot;{d:DesignInstance Type=vm:MainViewModel}&quot;
   
      &lt;Window.Resources&gt;
          &lt;vm:MainViewModel x:Key=&quot;mainViewModel&quot; /&gt;
      &lt;/Window.Resources&gt;
  </code></pre>
  <ol start="5">
  <li>I binded property command for buttons with created commands in view model.</li>
  </ol>
  <pre><code>&lt;Button Grid.Row=&quot;0&quot; Content=&quot;Sounds&quot; Command=&quot;{Binding Path=OpenSounds, 
              UpdateSourceTrigger=PropertyChanged}&quot; /&gt;
  </code></pre>
  <p>Compiler doesn't throw any exception, and .NET starts an application correctly, but commands doesn't work.</p>