title: WPF Delete button in listview mvvm
body: <p>I have a button inside a listview to delete selected item.when i click on the button RemoveSubjectCommand is not firing. if i put the button outside the listview it is working fine. hopw this is just because of nested item. how can i solve this problem?</p>
  
  <pre><code>&lt;ListView HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
          HorizontalContentAlignment="Stretch" Grid.ColumnSpan="3" Grid.Row="2"
          ItemsSource="{Binding AssignedSubjects}"&gt;
      &lt;ListView.ItemContainerStyle&gt;
          &lt;Style TargetType="ListViewItem"&gt;
              &lt;Setter Property="HorizontalContentAlignment" Value="Center" /&gt;
          &lt;/Style&gt;
      &lt;/ListView.ItemContainerStyle&gt;
      &lt;ListView.View&gt;
          &lt;GridView&gt;
              &lt;GridViewColumn Width="140" Header="Subjects" DisplayMemberBinding="{Binding Name}" /&gt;
              &lt;GridViewColumn Width="auto"&gt;
                  &lt;GridViewColumn.CellTemplate&gt;
                      &lt;DataTemplate&gt;
                          &lt;Button Content="X" Command="{Binding RemoveSubjectCommand}"  /&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/GridViewColumn.CellTemplate&gt;
              &lt;/GridViewColumn&gt;
          &lt;/GridView&gt;
      &lt;/ListView.View&gt;
  &lt;/ListView&gt;
  </code></pre>
  
  <p>View Model,</p>
  
  <pre><code>private ICommand removeSubjectCommand;
  **
  public ICommand RemoveSubjectCommand
  {
      get { return removeSubjectCommand ?? (removeSubjectCommand = new RelayCommand(param =&gt; this.RemoveSubject(), null)); }
  }
  **
  private void RemoveSubject()
  { ***
  }
  </code></pre>
  
  <p>If i put following code, it will work fine.</p>
  
  <pre><code>&lt;ListView.InputBindings&gt;
      &lt;KeyBinding Key="Delete" Command="{Binding RemoveSubjectCommand}" /&gt;
  &lt;/ListView.InputBindings&gt;
  </code></pre>