Listview ContextMenu Unclickable

时间:2015-11-25 15:16:23

标签: c# wpf contextmenu

所以我的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删除按钮:(我该如何解决这个问题?

0 个答案:

没有答案