自定义ContextMenu的外观样式





<!--自定义ContextMenu的外观样式-->
        <Style x:Key="ContextMenyStyle" TargetType="{x:Type ContextMenu}">
            <Setter Property="SnapsToDevicePixels" Value="true"/>
            <Setter Property="OverridesDefaultStyle" Value="true"/>
            <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
            <Setter Property="Focusable" Value="false" />
            <Setter Property="HasDropShadow" Value="true"/>
            <Setter Property="BorderThickness" Value="{TemplateBinding BorderThickness}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ContextMenu}">
                        <Border Name="Border" Background="{DynamicResource BorderBrush}" BorderBrush="{DynamicResource NormalBorderBrush}" BorderThickness="1" >
                            <StackPanel IsItemsHost="true" KeyboardNavigation.DirectionalNavigation="Cycle" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="HasDropShadow" Value="true">
                                <Setter TargetName="Border" Property="Padding" Value="0" />
                                <Setter TargetName="Border" Property="CornerRadius" Value="0" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>    
 <!--自定义菜单项之间的分隔符的样式-->
        <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
            <Setter Property="Height" Value="1" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Separator}">
                        <Border BorderBrush="#888888" BorderThickness="2" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <!--TopLevelHeader-->
        <ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
            <Border Name="Border">
                <Grid>
                    <ContentPresenter Margin="6 3 6 3" ContentSource="Header" RecognizesAccessKey="True">
                        <Popup Name="Popup" Placement="Bottom" IsOpen=&
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值