title: MVVM DataGrid SelectedItem binding doesn’t get updated
body: <p>I’m new to .Net and C# and a little bit confused with bindings. I have application that implements MVVM and displays DataGrid. What I want to implement is when user presses certain key combination then the content of currently selected cell gets copied to the cell in the row below.
  I have tried binding the SelectedItem of DataGrid to the ViewModel property but it never gets updated. CommandParameter also didn’t work, item count is always 0.
  So I cannot extract what cell the user has selected and cannot read the content of the selected cell.
  Does anyone have suggestions how to solve this problem or implement this functionality?
  Thanks in advance.
  code:
  xaml:</p>
  
  <pre><code>&lt;DataGrid Grid.Row="1" 
            Grid.Column="0" 
            Grid.ColumnSpan="9" 
            AutoGenerateColumns="False" 
            Height="Auto" 
            HorizontalAlignment="Left" 
            Name="dataGrid" 
            VerticalAlignment="Top" 
            Width="{Binding ElementName=grid4,Path=Width}"
            ScrollViewer.CanContentScroll="False" 
            FrozenColumnCount="1" 
            SelectionUnit="Cell" 
            SelectionMode="Extended" 
            CanUserSortColumns = "False" 
            CanUserReorderColumns="False" 
            CanUserResizeRows="False" 
            RowHeight="25" 
            RowBackground="LightGray" 
            AlternatingRowBackground="White"
            ScrollViewer.VerticalScrollBarVisibility="Visible" 
            ScrollViewer.HorizontalScrollBarVisibility="Visible"
            ItemsSource="{Binding Layers, Mode=TwoWay}"  
            SelectedItem="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.Selection, Mode=TwoWay}"&gt;
      &lt;DataGrid.InputBindings&gt;
          &lt;KeyBinding Gesture="Shift" 
                      Command="{Binding ItemHandler}" 
                      CommandParameter="{Binding ElementName=dataGrid, Path=SelectedItems}"&gt;
          &lt;/KeyBinding&gt;
      &lt;/DataGrid.InputBindings&gt;
  &lt;/DataGrid&gt;
  </code></pre>
  
  <p>ViewModel:</p>
  
  <pre><code>private float _selection = 0.0f;
      public float Selection
      {
          get
          {
              return _selection;
          }
          set
          {
              if (_selection != value)
              {
                  _selection = value;
                  NotifyPropertyChanged("Selection");
              }
          }
      }
  </code></pre>
  
  <p>...</p>
  
  <pre><code>        public DelegateCommand&lt;IList&gt; SelectionChangedCommand = new DelegateCommand&lt;IList&gt;(
          items =&gt;
          {
              if (items == null)
              {
                  NumberOfItemsSelected = 0; 
                  return;
              }
              NumberOfItemsSelected = items.Count;
          });
      public ICommand ItemHandler
      {
          get
          {
              return SelectionChangedCommand;
          }
      }
  </code></pre>