title: Is it possible to bind a WPF Event to MVVM ViewModel command?
body: <p>I have a xaml window and on the StateChanged event of the window I have to execute a piece of code. I have to follow MVVM. I binded the StateChanged property to an ICommand? It doesn't work. </p>
  
  <pre><code>&lt;Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="DummyApp"
  x:Name="Window"
  Title="Dummy App"
  Width="{Binding WindowWidth,Mode=OneWayToSource}" Height="{Binding WindowHeight}" ResizeMode="CanMinimize" Icon="Logo.png" SizeToContent="WidthAndHeight"  WindowStartupLocation="CenterScreen" WindowState="{Binding CurrentWindowState, Mode=TwoWay}"
  ShowInTaskbar="{Binding ShowInTaskBar, Mode=TwoWay}" StateChanged="{Binding IsMinimized}"&gt;
  </code></pre>
  
  <p>This is my viewmodel.</p>
  
  <pre><code>public ICommand IsMinimized
      {
          get
          {
              if (_IsMinimized == null)
              {
                  _IsMinimized = new RelayCommand(param =&gt; this.OnMinimized(), null);
              }
              return _IsMinimized;
          }
      }
  
      private void OnMinimized()
      {
          //do something here
      }
  </code></pre>
  
  <p>Is there anyother way to do this?</p>