title: getting items from context menu in binding listview WPF c#
body: <p>I'am new in Microsoft visual studio WPF C# ..
  I write code that show a context menu for binding listview and when we right click to the item in list it will remove it ...
  I want to get the value of the item before we remove it </p>
  
  <p>**the xaml</p>
  
  <pre><code>&lt;ListView Name="listview1" HorizontalAlignment="Left" Height="350" Margin="251,63,0,0" VerticalAlignment="Top" Width="214" FontSize="16" FontWeight="Bold"&gt;
          &lt;ListView.ContextMenu&gt;
              &lt;ContextMenu&gt;
                  &lt;MenuItem Header="Remove"
                  Click="MenuItemDelete_Click" 
          Command="{Binding RemoveItem}"
          CommandParameter="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.SelectedItem}" /&gt;
              &lt;/ContextMenu&gt;
  
          &lt;/ListView.ContextMenu&gt;
          &lt;ListView.View&gt;
              &lt;GridView&gt;
                  &lt;GridView.Columns&gt;
  
                      &lt;GridViewColumn x:Name="Dtime" DisplayMemberBinding=
                        "{Binding Path=Dtime}" 
                    Header=" Date" Width="120"/&gt;
                      &lt;GridViewColumn x:Name="Patient"  DisplayMemberBinding=
                        "{Binding Path=Patient}"   
                    Header="Patient" Width="80"/&gt;
                  &lt;/GridView.Columns&gt;
              &lt;/GridView&gt;
          &lt;/ListView.View&gt;
  </code></pre>
  
  <p>**the code </p>
  
  <pre><code> class myresult {
  
          public String Dtime{ get; set; }
          public String Patient{ get; set; }
  
      }
  
  
  
  
   private void MenuItemDelete_Click(object sender, RoutedEventArgs e)
      {
  
              if (listview1.SelectedIndex == -1)
              {
                  return;
              }
  
  // here I will get the Item I want but I cant get the value inside the item                 
  
         var asw = listview1.Items.GetItemAt(listview1.SelectedIndex);
  
  
  
          listview1.Items.RemoveAt(listview1.SelectedIndex);
      }
  </code></pre>