ContextMenu.axaml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  2. <ControlTheme x:Key="SukiContextMenuStyle" TargetType="ContextMenu">
  3. <Setter Property="Background" Value="{DynamicResource SukiCardBackground}" />
  4. <Setter Property="CornerRadius" Value="6" />
  5. <Setter Property="BorderBrush" Value="{DynamicResource SukiMenuBorderBrush}" />
  6. <Setter Property="BorderThickness" Value="1" />
  7. <Setter Property="Template">
  8. <ControlTemplate>
  9. <!-- Tiny margin helps prevent mouse-over immediately -->
  10. <LayoutTransformControl Name="PART_LayoutTransform"
  11. Margin="1,0,0,0"
  12. RenderTransformOrigin="0%, 0%">
  13. <Panel>
  14. <Border Margin="16"
  15. BoxShadow="{DynamicResource SukiPopupShadow}"
  16. CornerRadius="{TemplateBinding CornerRadius}" />
  17. <Border Margin="15"
  18. Background="{TemplateBinding Background}"
  19. BorderBrush="{TemplateBinding BorderBrush}"
  20. BorderThickness="{TemplateBinding BorderThickness}"
  21. ClipToBounds="True"
  22. CornerRadius="{TemplateBinding CornerRadius}">
  23. <Panel Background="{DynamicResource PopupGradientBrush}">
  24. <ItemsPresenter Name="PART_ItemsPresenter"
  25. HorizontalAlignment="Left"
  26. VerticalAlignment="Center"
  27. ItemsPanel="{TemplateBinding ItemsPanel}"
  28. KeyboardNavigation.TabNavigation="Continue" />
  29. </Panel>
  30. </Border>
  31. </Panel>
  32. </LayoutTransformControl>
  33. </ControlTemplate>
  34. </Setter>
  35. <Style Selector="^[IsOpen=True] /template/ LayoutTransformControl#PART_LayoutTransform">
  36. <Style.Animations>
  37. <Animation Easing="{StaticResource MenuEasing}"
  38. FillMode="Forward"
  39. Duration="{StaticResource ShortAnimationDuration}">
  40. <KeyFrame Cue="0%">
  41. <Setter Property="ScaleTransform.ScaleY" Value="0.92" />
  42. <Setter Property="ScaleTransform.ScaleX" Value="0.92" />
  43. <Setter Property="Opacity" Value="0" />
  44. </KeyFrame>
  45. <KeyFrame Cue="100%">
  46. <Setter Property="ScaleTransform.ScaleY" Value="1" />
  47. <Setter Property="ScaleTransform.ScaleX" Value="1" />
  48. <Setter Property="Opacity" Value="1" />
  49. </KeyFrame>
  50. </Animation>
  51. </Style.Animations>
  52. </Style>
  53. </ControlTheme>
  54. <ControlTheme x:Key="{x:Type ContextMenu}"
  55. BasedOn="{StaticResource SukiContextMenuStyle}"
  56. TargetType="ContextMenu" />
  57. </ResourceDictionary>