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

View file

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