ListView添加右键菜单
Posted 逛园子$$$
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ListView添加右键菜单相关的知识,希望对你有一定的参考价值。
<ListView x:Name="deviceListView" FontSize="18" Background="Transparent" BorderThickness="0" Foreground="#FF1BE2E2" Style="{DynamicResource ListViewStyle2}"> <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="true"> <Setter Property="Background" Value="Transparent"/> <Setter Property="Foreground" Value="white"></Setter> <Setter Property="Opacity" Value="0.75"></Setter> </Trigger> <Trigger Property="IsSelected" Value="true"> <Setter Property="Foreground" Value="white"></Setter> <Setter Property="Background" Value="Transparent"></Setter> <Setter Property="Opacity" Value="1"></Setter> </Trigger> </Style.Triggers> </Style> </ListView.ItemContainerStyle> <ListView.ContextMenu> <ContextMenu > <MenuItem Header="详情"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <Custom:EventToCommand Command="{Binding DevicesSetCmd}" CommandParameter="0"/> </i:EventTrigger> </i:Interaction.Triggers> </MenuItem> <MenuItem Header="删除"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <Custom:EventToCommand Command="{Binding DevicesSetCmd}" CommandParameter="1"/> </i:EventTrigger> </i:Interaction.Triggers> </MenuItem> <MenuItem Header="修改"> <i:Interaction.Triggers> <i:EventTrigger EventName="Click"> <Custom:EventToCommand Command="{Binding DevicesSetCmd}" CommandParameter="3"/> </i:EventTrigger> </i:Interaction.Triggers> </MenuItem> </ContextMenu> </ListView.ContextMenu> <ListView.View> <GridView> <GridViewColumn Header="序号" Width="80" /> <GridViewColumn Header="名称" /> </GridView> </ListView.View> </ListView>
以上是关于ListView添加右键菜单的主要内容,如果未能解决你的问题,请参考以下文章
VB中如何在ListView中添加ImageList中的图像