所以我的contextmenu
代码中有xaml
<ListView x:Name="listView" Grid.Row="1" SelectionChanged="listView_SelectionChanged" IsEnabled="True">
<ListView.ContextMenu>
<ContextMenu>
<MenuItem Command="Delete" IsEnabled="True" Click="MenuItem_Click"></MenuItem>
</ContextMenu>
</ListView.ContextMenu>
</ListView>
然后在我的c#
代码中
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
listView.Items.Remove(listView.SelectedItems[0]);
showList.RemoveAt(listView.Items.IndexOf(listView.SelectedItems[0]));
}
但不幸的是,当我调试我的程序它不会让我点击contextmenu
删除按钮:(我该如何解决这个问题?