Files
ShrlAlgoToolkit/Melskin/Controls/Menu.xaml
2026-02-20 15:31:44 +08:00

611 lines
33 KiB
XML

<ResourceDictionary
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:assists="clr-namespace:Melskin.Assists"
xmlns:controls="clr-namespace:Melskin.Controls"
xmlns:decorations="clr-namespace:Melskin.Controls.Decorations"
xmlns:markup="clr-namespace:Melskin.Markup">
<!-- 菜单栏样式 -->
<Style TargetType="{x:Type Menu}">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Menu}">
<Border
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
SnapsToDevicePixels="true">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!--<SolidColorBrush Color="#0A000000" x:Key="MenuItem.Highlight.Disabled.Background" />
<SolidColorBrush Color="#21000000" x:Key="MenuItem.Highlight.Disabled.Border" />-->
<MenuScrollingVisibilityConverter x:Key="MenuScrollingVisibilityConverter" />
<Style
x:Key="MenuScrollButtonStyle"
BasedOn="{x:Null}"
TargetType="{x:Type RepeatButton}">
<Setter Property="ClickMode" Value="Hover" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type RepeatButton}">
<Border
x:Name="templateRoot"
Background="Transparent"
BorderBrush="Transparent"
BorderThickness="1"
SnapsToDevicePixels="true">
<!--<ContentPresenter
Margin="6"
HorizontalAlignment="Center"
VerticalAlignment="Center" />-->
<ContentPresenter
x:Name="Icon"
Margin="6"
Content="{Binding Path=(assists:ControlAssist.Icon), RelativeSource={RelativeSource TemplatedParent}}"
TextElement.Foreground="{DynamicResource TextSecondaryBrush}" />
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style
x:Key="{ComponentResourceKey ResourceId=MenuScrollViewer,
TypeInTargetAssembly={x:Type FrameworkElement}}"
BasedOn="{x:Null}"
TargetType="{x:Type ScrollViewer}">
<Setter Property="HorizontalScrollBarVisibility" Value="Hidden" />
<Setter Property="VerticalScrollBarVisibility" Value="Auto" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ScrollViewer}">
<Grid SnapsToDevicePixels="true">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Border Grid.Row="1" Grid.Column="0">
<ScrollContentPresenter Margin="{TemplateBinding Padding}" CanContentScroll="{TemplateBinding CanContentScroll}" />
</Border>
<RepeatButton
Grid.Row="0"
Grid.Column="0"
assists:ControlAssist.Icon="{markup:Icon SymbolValue=ArrowDropUp}"
Command="{x:Static ScrollBar.LineUpCommand}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
Focusable="false"
Style="{StaticResource MenuScrollButtonStyle}">
<RepeatButton.Visibility>
<MultiBinding
Converter="{StaticResource MenuScrollingVisibilityConverter}"
ConverterParameter="0"
FallbackValue="Visibility.Collapsed">
<Binding Path="ComputedVerticalScrollBarVisibility" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="VerticalOffset" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="ExtentHeight" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="ViewportHeight" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</RepeatButton.Visibility>
</RepeatButton>
<RepeatButton
Grid.Row="2"
Grid.Column="0"
assists:ControlAssist.Icon="{markup:Icon SymbolValue=ArrowDropDown}"
Command="{x:Static ScrollBar.LineDownCommand}"
CommandTarget="{Binding RelativeSource={RelativeSource TemplatedParent}}"
Focusable="false"
Style="{StaticResource MenuScrollButtonStyle}">
<RepeatButton.Visibility>
<MultiBinding
Converter="{StaticResource MenuScrollingVisibilityConverter}"
ConverterParameter="100"
FallbackValue="Visibility.Collapsed">
<Binding Path="ComputedVerticalScrollBarVisibility" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="VerticalOffset" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="ExtentHeight" RelativeSource="{RelativeSource TemplatedParent}" />
<Binding Path="ViewportHeight" RelativeSource="{RelativeSource TemplatedParent}" />
</MultiBinding>
</RepeatButton.Visibility>
</RepeatButton>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<!-- 顶层菜单 -->
<ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
<Border
x:Name="templateRoot"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="true">
<Grid VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="Icon"
Width="16"
Height="16"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<controls:IconElement
x:Name="GlyphPanel"
Grid.Column="0"
Margin="2"
VerticalAlignment="Center"
FlowDirection="LeftToRight"
Foreground="{DynamicResource PrimaryGradientBrush}"
Symbol="Check"
Visibility="Collapsed" />
<ContentPresenter
Grid.Column="1"
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
ContentSource="Header"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="{DynamicResource ControlBackgroundSelectedBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="templateRoot" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter TargetName="GlyphPanel" Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
</Trigger>
<!-- TODO:调整此处样式 -->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsHighlighted" Value="True" />
<Condition Property="IsEnabled" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="templateRoot" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter TargetName="templateRoot" Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!-- 顶层带子项的菜单 -->
<ControlTemplate x:Key="{ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
<Border
x:Name="templateRoot"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="true">
<Grid VerticalAlignment="Center">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="Icon"
Width="16"
Height="16"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<controls:IconElement
x:Name="GlyphPanel"
Grid.Column="0"
Margin="3"
VerticalAlignment="Center"
FlowDirection="LeftToRight"
Foreground="{DynamicResource PrimaryGradientBrush}"
Symbol="Check"
Visibility="Collapsed" />
<ContentPresenter
Grid.Column="1"
Margin="{TemplateBinding Padding}"
ContentSource="Header"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<!-- 打开子菜单面板 -->
<Popup
x:Name="PART_Popup"
Grid.Column="0"
AllowsTransparency="true"
Focusable="false"
IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Bottom"
PlacementTarget="{Binding ElementName=templateRoot}"
PopupAnimation="Fade">
<decorations:LightedSurface
Margin="8"
Padding="0"
BorderBrush="{DynamicResource BorderGradientBrush}"
BorderThickness="1"
Effect="{DynamicResource PopupShadow}">
<Border x:Name="SubMenuBorder" Margin="2,1">
<ScrollViewer x:Name="SubMenuScrollViewer" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
<Grid RenderOptions.ClearTypeHint="Enabled">
<Canvas
Width="0"
Height="0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Rectangle
x:Name="OpaqueRect"
Width="{Binding ActualWidth, ElementName=SubMenuBorder}"
Height="{Binding ActualHeight, ElementName=SubMenuBorder}"
Fill="{Binding Background, ElementName=SubMenuBorder}" />
</Canvas>
<ItemsPresenter
x:Name="ItemsPresenter"
Grid.IsSharedSizeScope="true"
KeyboardNavigation.DirectionalNavigation="Cycle"
KeyboardNavigation.TabNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</ScrollViewer>
</Border>
</decorations:LightedSurface>
</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSuspendingPopupAnimation" Value="true">
<Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="true">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="templateRoot" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter TargetName="GlyphPanel" Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
</Trigger>
<Trigger SourceName="SubMenuScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false">
<Setter TargetName="OpaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=SubMenuScrollViewer}" />
<Setter TargetName="OpaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=SubMenuScrollViewer}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!-- 弹出菜单 -->
<ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
<Border
x:Name="templateRoot"
Height="28"
Margin="0,1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="true">
<Grid Margin="-1">
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="Auto"
MinWidth="22"
SharedSizeGroup="MenuItemIconColumnGroup" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
<ColumnDefinition Width="12" />
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="Icon"
Width="16"
Height="16"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Border
x:Name="GlyphPanel"
Grid.Column="0"
Width="22"
Height="22"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="{DynamicResource ControlBackgroundSelectedBrush}"
ClipToBounds="False"
CornerRadius="4"
Visibility="Hidden">
<controls:IconElement
x:Name="Glyph"
Margin="4"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FlowDirection="LeftToRight"
Foreground="{DynamicResource PrimaryGradientBrush}"
Symbol="Check" />
</Border>
<ContentPresenter
x:Name="menuHeaderContainer"
Grid.Column="1"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ContentSource="Header"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<TextBlock
x:Name="menuGestureText"
Grid.Column="3"
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
Opacity="0.7"
Text="{TemplateBinding InputGestureText}" />
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="templateRoot" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter TargetName="Glyph" Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
</Trigger>
<!-- TODO:更改样式 -->
<MultiTrigger>
<MultiTrigger.Conditions>
<Condition Property="IsHighlighted" Value="True" />
<Condition Property="IsEnabled" Value="False" />
</MultiTrigger.Conditions>
<Setter TargetName="templateRoot" Property="Background" Value="{DynamicResource ControlBackgroundDisabledBrush}" />
<Setter TargetName="templateRoot" Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
</MultiTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!-- 弹出带子项菜单 -->
<ControlTemplate x:Key="{ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}" TargetType="{x:Type MenuItem}">
<Border
x:Name="templateRoot"
Height="28"
Margin="0,1"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="4"
SnapsToDevicePixels="true">
<Grid Margin="-1">
<Grid.ColumnDefinitions>
<ColumnDefinition
Width="Auto"
MinWidth="22"
SharedSizeGroup="MenuItemIconColumnGroup" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="30" />
<ColumnDefinition Width="Auto" SharedSizeGroup="MenuItemIGTColumnGroup" />
<ColumnDefinition Width="12" />
</Grid.ColumnDefinitions>
<ContentPresenter
x:Name="Icon"
Width="16"
Height="16"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
ContentSource="Icon"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<Border
x:Name="GlyphPanel"
Grid.Column="0"
Width="22"
Height="22"
Margin="3"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="{DynamicResource ControlBackgroundSelectedBrush}"
CornerRadius="4"
Visibility="Hidden">
<controls:IconElement
x:Name="Glyph"
Margin="4"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FlowDirection="LeftToRight"
Foreground="{DynamicResource PrimaryGradientBrush}"
Symbol="Check" />
</Border>
<ContentPresenter
Grid.Column="1"
Margin="{TemplateBinding Padding}"
HorizontalAlignment="Left"
VerticalAlignment="Center"
ContentSource="Header"
RecognizesAccessKey="True"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
<TextBlock
Grid.Column="3"
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
Opacity="0.7"
Text="{TemplateBinding InputGestureText}" />
<controls:IconElement
x:Name="ArrowRight"
Grid.Column="4"
Foreground="{DynamicResource TextPrimaryBrush}"
Symbol="KeyboardArrowRight" />
<Popup
x:Name="PART_Popup"
Grid.Column="0"
AllowsTransparency="true"
Focusable="false"
HorizontalOffset="-2"
IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}"
Placement="Right"
PopupAnimation="Fade"
VerticalOffset="-3">
<decorations:LightedSurface
Margin="8"
Padding="0"
BorderBrush="{DynamicResource BorderGradientBrush}"
BorderThickness="1"
Effect="{DynamicResource PopupShadow}">
<Border x:Name="SubMenuBorder" Margin="2,1">
<ScrollViewer x:Name="SubMenuScrollViewer" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
<Grid RenderOptions.ClearTypeHint="Enabled">
<Canvas
Width="0"
Height="0"
HorizontalAlignment="Left"
VerticalAlignment="Top">
<Rectangle
x:Name="OpaqueRect"
Width="{Binding ActualWidth, ElementName=SubMenuBorder}"
Height="{Binding ActualHeight, ElementName=SubMenuBorder}"
Fill="{Binding Background, ElementName=SubMenuBorder}" />
</Canvas>
<ItemsPresenter
x:Name="ItemsPresenter"
Grid.IsSharedSizeScope="true"
KeyboardNavigation.DirectionalNavigation="Cycle"
KeyboardNavigation.TabNavigation="Cycle"
SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
</Grid>
</ScrollViewer>
</Border>
</decorations:LightedSurface>
</Popup>
</Grid>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSuspendingPopupAnimation" Value="true">
<Setter TargetName="PART_Popup" Property="PopupAnimation" Value="None" />
</Trigger>
<Trigger Property="Icon" Value="{x:Null}">
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="GlyphPanel" Property="Visibility" Value="Visible" />
<Setter TargetName="Icon" Property="Visibility" Value="Collapsed" />
</Trigger>
<Trigger Property="IsHighlighted" Value="True">
<Setter TargetName="templateRoot" Property="Background" Value="{DynamicResource BackgroundFloatingBrush}" />
</Trigger>
<Trigger Property="IsEnabled" Value="False">
<Setter TargetName="templateRoot" Property="TextElement.Foreground" Value="{DynamicResource TextDisabledBrush}" />
<Setter TargetName="Glyph" Property="Foreground" Value="{DynamicResource PrimaryDisabledBrush}" />
<Setter TargetName="ArrowRight" Property="Foreground" Value="{DynamicResource TextDisabledBrush}" />
</Trigger>
<Trigger SourceName="SubMenuScrollViewer" Property="ScrollViewer.CanContentScroll" Value="false">
<Setter TargetName="OpaqueRect" Property="Canvas.Top" Value="{Binding VerticalOffset, ElementName=SubMenuScrollViewer}" />
<Setter TargetName="OpaqueRect" Property="Canvas.Left" Value="{Binding HorizontalOffset, ElementName=SubMenuScrollViewer}" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<!-- 菜单栏项目样式 -->
<Style TargetType="{x:Type MenuItem}">
<Setter Property="FontSize" Value="14" />
<Setter Property="Padding" Value="2,0" />
<Setter Property="HorizontalContentAlignment" Value="{Binding HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="VerticalContentAlignment" Value="{Binding VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="ScrollViewer.PanningMode" Value="Both" />
<Setter Property="Stylus.IsFlicksEnabled" Value="False" />
<!-- 默认弹出式菜单 -->
<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
<Style.Triggers>
<!-- 顶层带子项的菜单 -->
<Trigger Property="Role" Value="TopLevelHeader">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="Transparent" />
<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
<Setter Property="Padding" Value="6,0" />
</Trigger>
<!-- 顶层菜单 -->
<Trigger Property="Role" Value="TopLevelItem">
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderNormalBrush}" />
<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=TopLevelItemTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
<Setter Property="Padding" Value="6,0" />
</Trigger>
<!-- 弹出带子项菜单 -->
<Trigger Property="Role" Value="SubmenuHeader">
<Setter Property="Template" Value="{DynamicResource {ComponentResourceKey ResourceId=SubmenuHeaderTemplateKey, TypeInTargetAssembly={x:Type MenuItem}}}" />
</Trigger>
</Style.Triggers>
</Style>
<!-- 右键菜单样式 -->
<Style TargetType="{x:Type ContextMenu}">
<Setter Property="FontSize" Value="14" />
<Setter Property="Padding" Value="2,0" />
<Setter Property="Foreground" Value="{DynamicResource TextPrimaryBrush}" />
<Setter Property="Background" Value="{DynamicResource BackgroundLayoutBrush}" />
<Setter Property="BorderBrush" Value="{DynamicResource BorderGradientBrush}" />
<Setter Property="BorderThickness" Value="1" />
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="OverridesDefaultStyle" Value="True" />
<Setter Property="Grid.IsSharedSizeScope" Value="true" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Grid>
<Border
x:Name="Border"
Margin="8"
Padding="0"
Background="{TemplateBinding Background}"
BorderThickness="0"
CornerRadius="4"
Effect="{DynamicResource PopupShadow}">
<StackPanel
Margin="2,1"
IsItemsHost="True"
KeyboardNavigation.DirectionalNavigation="Cycle" />
</Border>
<Rectangle
Margin="8"
RadiusX="4"
RadiusY="4"
Stroke="{TemplateBinding BorderBrush}"
StrokeThickness="{TemplateBinding BorderThickness}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>