style<ContextMenu>: use DropShadowEffect instead a solid border for ContextMenu

This commit is contained in:
leo 2021-02-25 19:00:43 +08:00
parent 8c1445ff0c
commit f98ba79c09
2 changed files with 24 additions and 9 deletions

View file

@ -12,12 +12,21 @@
<Style TargetType="{x:Type ContextMenu}">
<Setter Property="SnapsToDevicePixels" Value="True" />
<Setter Property="Grid.IsSharedSizeScope" Value="False" />
<Setter Property="HorizontalOffset" Value="-12"/>
<Setter Property="VerticalOffset" Value="-12"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border Background="{DynamicResource Brush.Popup}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border1}">
<StackPanel IsItemsHost="True" Margin="1" KeyboardNavigation.DirectionalNavigation="Cycle"/>
</Border>
<Grid RenderTransformOrigin="12,12">
<Border Background="{DynamicResource Brush.Popup}" BorderThickness="0" Margin="12">
<Border.Effect>
<DropShadowEffect BlurRadius="12" ShadowDepth="0" Color="Black"/>
</Border.Effect>
</Border>
<StackPanel IsItemsHost="True" Margin="14" KeyboardNavigation.DirectionalNavigation="Cycle"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
@ -59,12 +68,18 @@
<ContentPresenter Name="Icon" Grid.Column="0" Margin="6,0" VerticalAlignment="Center" ContentSource="Icon"/>
<ContentPresenter Name="HeadHost" Grid.Column="1" Margin="0,0,8,0" ContentSource="Header" VerticalAlignment="Center"/>
<Path Grid.Column="2" Width="8" Height="8" Style="{DynamicResource Style.Icon}" Data="M 0 0 L 0 7 L 4 3.5 Z"/>
<Popup Name="Popup" Placement="Right" HorizontalOffset="-2" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
<Border Name="SubmenuBorder" SnapsToDevicePixels="True" Background="{DynamicResource Brush.Popup}" BorderBrush="{DynamicResource Brush.Border1}" BorderThickness="1">
<ScrollViewer HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
<Popup Name="Popup" Placement="Right" HorizontalOffset="-14" VerticalOffset="-12" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
<Grid>
<Border Background="{DynamicResource Brush.Popup}" BorderThickness="0" Margin="12">
<Border.Effect>
<DropShadowEffect BlurRadius="12" ShadowDepth="0" Color="Black"/>
</Border.Effect>
</Border>
<ScrollViewer Margin="14" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto" CanContentScroll="True">
<StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle"/>
</ScrollViewer>
</Border>
</Grid>
</Popup>
</Grid>
</Border>
@ -85,7 +100,7 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Separator}">
<Rectangle Height=".8" VerticalAlignment="Center" SnapsToDevicePixels="True" Fill="{DynamicResource Brush.Border1}"/>
<Rectangle Height=".8" VerticalAlignment="Center" SnapsToDevicePixels="True" Fill="{DynamicResource Brush.Border2}"/>
</ControlTemplate>
</Setter.Value>
</Setter>

View file

@ -852,7 +852,7 @@ namespace SourceGit.UI {
anchor.ContextMenu = new ContextMenu();
anchor.ContextMenu.PlacementTarget = anchor;
anchor.ContextMenu.Placement = PlacementMode.Top;
anchor.ContextMenu.VerticalOffset = -4;
anchor.ContextMenu.VerticalOffset = 8;
anchor.ContextMenu.StaysOpen = false;
anchor.ContextMenu.Focusable = true;
anchor.ContextMenu.MaxWidth = 500;