title: MVVM Binding buttons in ListView item within a ItemTemplate
body: <p>In a UWP-Windows 10 C#/XAML app using MVVM and Template10, I'm currently trying to bind buttons inside a ListView item to methods in the ViewModel in the following way:</p>
  
  <pre><code>&lt;Page.Resources&gt;
      &lt;DataTemplate x:DataType="vm:ViewModel" x:Key="TermListViewTemplate"&gt;
          &lt;Grid&gt;
              &lt;ListView x:Name="termListView" 
                        ItemsSource="{x:Bind childModels, Mode=OneWay}"
                        ItemClick="EntityListClick"&gt;
                  &lt;ListView.ItemTemplate&gt;
                      &lt;DataTemplate x:DataType="gl:Term"&gt;
                          &lt;Grid HorizontalAlignment="Stretch"&gt;
                              &lt;StackPanel&gt;
                                  &lt;Button Click="EditButton_Click"&gt;
                                      &lt;SymbolIcon Symbol="Edit"&gt;&lt;/SymbolIcon&gt;
                                  &lt;/Button&gt;
                                  &lt;Button Click="DeleteButton_Click"&gt;
                                      &lt;SymbolIcon Symbol="Delete"&gt;&lt;/SymbolIcon&gt;
                                  &lt;/Button&gt;
                              &lt;/StackPanel&gt;
                          &lt;/Grid&gt;
                      &lt;/DataTemplate&gt;
                  &lt;/ListView.ItemTemplate&gt;
              &lt;/ListView&gt;
          &lt;/Grid&gt;
      &lt;/DataTemplate&gt;
  &lt;/Page.Resources&gt;
  </code></pre>
  
  <p>Where <code>EntityListClick</code>, <code>EditButton_Click</code>, and <code>DeleteButton_Click</code> are all methods in the codebehind file, that then call a method in the <code>ViewModel</code> as so:</p>
  
  <pre><code>private void EntityListClick(object sender, ItemClickEventArgs e)
  {
      ViewModel.termClick((Term)e.ClickedItem);
  }
  
  private void EditButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
  {
      ViewModel.editTerm((Term)(sender as Button).DataContext);
  }
  
  private void DeleteButton_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
  {
      ViewModel.deleteTerm((Term)(sender as Button).DataContext);
  }
  </code></pre>
  
  <p>How would I correctly implement the MVVM patterns in this scenario to directly bind to <code>ViewModel.termClick</code>, <code>ViewModel.editTerm</code>, and <code>ViewModel.deleteTerm</code>, in the <code>ViewModel</code> while passing the correct parameter to the <code>ViewModel</code>?</p>
  
  <p>Additionally I have a button in the XAML whose <code>Click</code> event handler is attached to the following method in the code behind:</p>
  
  <pre><code>private async void AddTerm_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
  {
      await ViewModel.addTermAsync();
      ListView termListView = (ListView)((Grid)((Button)sender).Parent).Children[2];
      termListView.ScrollIntoView(termListView.Items[termListView.Items.Count - 1]);
  }
  </code></pre>
  
  <p>Once again, is there some way to properly link the click handler to the ViewModel directly, in such a way that the ListView can be scrolled? (perhaps some way of binding the ListView's entire instance to a property of type "ListView" in the ViewModel?)</p>