resources/xaml/styles/ContextMenuStyle.xaml
|
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <!-- Separator style for ContextMenu (keyed, applied via ContextMenu.Resources) --> <Style x:Key="ContextMenuSeparatorStyle" TargetType="Separator"> <Setter Property="Margin" Value="0,4,0,4"/> <Setter Property="Focusable" Value="False"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="Separator"> <Border Height="1" Background="{DynamicResource BorderBrush}" SnapsToDevicePixels="True"/> </ControlTemplate> </Setter.Value> </Setter> </Style> <!-- VS Code-style ContextMenu --> <Style TargetType="ContextMenu"> <Setter Property="Background" Value="{DynamicResource ControlBackgroundBrush}"/> <Setter Property="Foreground" Value="{DynamicResource ControlForegroundBrush}"/> <Setter Property="BorderBrush" Value="{DynamicResource BorderBrush}"/> <Setter Property="BorderThickness" Value="1"/> <Setter Property="Padding" Value="0,4"/> <Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="FontSize" Value="13"/> <Setter Property="HasDropShadow" Value="True"/> <Setter Property="SnapsToDevicePixels" Value="True"/> <Setter Property="Grid.IsSharedSizeScope" Value="True"/> <Setter Property="MaxWidth" Value="360"/> <Setter Property="MinWidth" Value="180"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="ContextMenu"> <Border x:Name="Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="6" Padding="{TemplateBinding Padding}" SnapsToDevicePixels="True"> <Border.Effect> <DropShadowEffect BlurRadius="16" ShadowDepth="4" Opacity="0.35" Direction="270"/> </Border.Effect> <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" HorizontalAlignment="Stretch"/> </Border> </ControlTemplate> </Setter.Value> </Setter> </Style> <!-- VS Code-style MenuItem - full width --> <Style TargetType="MenuItem"> <Setter Property="Background" Value="Transparent"/> <Setter Property="Foreground" Value="{DynamicResource ControlForegroundBrush}"/> <Setter Property="Padding" Value="0"/> <Setter Property="Margin" Value="0"/> <Setter Property="FontFamily" Value="Segoe UI"/> <Setter Property="FontSize" Value="13"/> <Setter Property="SnapsToDevicePixels" Value="True"/> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="MenuItem"> <Border x:Name="Border" Background="{TemplateBinding Background}" Padding="26,6,20,6" SnapsToDevicePixels="True"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" SharedSizeGroup="IconColumn"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto" SharedSizeGroup="ShortcutColumn"/> </Grid.ColumnDefinitions> <!-- Icon column --> <ContentPresenter x:Name="Icon" Grid.Column="0" ContentSource="Icon" Width="16" Height="16" Margin="0,0,10,0" VerticalAlignment="Center" Visibility="Collapsed"/> <!-- Header text --> <ContentPresenter x:Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True" VerticalAlignment="Center"/> <!-- Keyboard shortcut --> <TextBlock x:Name="InputGestureText" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Foreground="{DynamicResource SecondaryTextBrush}" FontSize="12" Margin="40,0,0,0" VerticalAlignment="Center" Opacity="0.6"/> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="Icon" Value="{x:Null}"> <Setter TargetName="Icon" Property="Visibility" Value="Collapsed"/> </Trigger> <Trigger Property="IsHighlighted" Value="True"> <Setter TargetName="Border" Property="Background" Value="{DynamicResource ItemHoverBrush}"/> </Trigger> <Trigger Property="IsEnabled" Value="False"> <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}"/> <Setter Property="Opacity" Value="0.5"/> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> </ResourceDictionary> |