码迷,mamicode.com
首页 > 其他好文 > 详细

ListView添加右键菜单

时间:2018-05-22 12:57:27      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:context   comm   nes   pre   contex   view   width   binding   selected   

<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添加右键菜单

标签:context   comm   nes   pre   contex   view   width   binding   selected   

原文地址:https://www.cnblogs.com/LY-HeroesRebor/p/9070987.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!