ContextMenu样式
对应的xaml代码:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Style TargetType="{x:Type ContextMenu}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ContextMenu}"> <Border BorderThickness="1" Grid.Column="2" Grid.Row="1"> <Border Name="Border" BorderThickness="1" Grid.Column="2" Grid.Row="1" Margin="5" BorderBrush="#e2e2e2" Background="{DynamicResource {x:Static SystemColors.WindowBrushKey}}" Padding="10" CornerRadius="12"> <Border.Effect> <!--阴影--> <DropShadowEffect Color="Gray" ShadowDepth="0" BlurRadius="5" Opacity="0.3" Direction="0"/> </Border.Effect> <!--重点:右建菜单的Items--> <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/> </Border> </Border> <ControlTemplate.Triggers> <Trigger Property="HasDropShadow" Value="true"> <Setter TargetName="Border" Property="Padding" Value="0,3,0,3"/> <Setter TargetName="Border" Property="CornerRadius" Value="4"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary>
标签:代码,自定义,ContextMenu,样式,xaml,对应 From: https://www.cnblogs.com/cdaniu/p/18139959