feat: 1. set menu and menu item default background to transparent.

2. add corner radius to menuitem.
This commit is contained in:
rabbitism 2024-09-26 22:24:49 +08:00
parent 32ff9735ee
commit eb11d78fab
No known key found for this signature in database
4 changed files with 18 additions and 12 deletions

View File

@ -92,12 +92,12 @@
</ControlTheme>
<ControlTheme x:Key="{x:Type Separator}" TargetType="Separator">
<Setter Property="Separator.Background" Value="{DynamicResource MenuItemSeparatorBackground}" />
<Setter Property="Separator.Focusable" Value="False" />
<Setter Property="Separator.Height" Value="{DynamicResource MenuItemSeparatorHeight}" />
<Setter Property="Separator.HorizontalAlignment" Value="Stretch" />
<Setter Property="Separator.Margin" Value="{DynamicResource MenuItemSeparatorMargin}" />
<Setter Property="Separator.Template">
<Setter Property="Background" Value="{DynamicResource MenuItemSeparatorBackground}" />
<Setter Property="Focusable" Value="False" />
<Setter Property="Height" Value="{DynamicResource MenuItemSeparatorHeight}" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="Margin" Value="{DynamicResource MenuItemSeparatorMargin}" />
<Setter Property="Template">
<ControlTemplate TargetType="Separator">
<Border
Height="{TemplateBinding Height}"
@ -115,7 +115,8 @@
<ControlTheme x:Key="{x:Type MenuItem}" TargetType="MenuItem">
<Setter Property="Background" Value="{DynamicResource MenuItemBackground}" />
<Setter Property="Foreground" Value="{DynamicResource MenuItemForeground}" />
<Setter Property="MenuItem.Cursor" Value="Hand" />
<Setter Property="CornerRadius" Value="{DynamicResource MenuItemCornerRadius}" />
<Setter Property="Cursor" Value="Hand" />
<!-- Narrow padding should be used for mouse input, when non-narrow one should be used for touch input in future. -->
<Setter Property="Padding" Value="{DynamicResource MenuItemPadding}" />
<Setter Property="Template">
@ -293,7 +294,8 @@
<ControlTheme x:Key="TopLevelMenuItem" TargetType="MenuItem">
<Setter Property="Background" Value="{DynamicResource MenuItemBackground}" />
<Setter Property="Foreground" Value="{DynamicResource MenuItemForeground}" />
<Setter Property="MenuItem.Cursor" Value="Hand" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="CornerRadius" Value="{DynamicResource MenuItemCornerRadius}"/>
<!-- Narrow padding should be used for mouse input, when non-narrow one should be used for touch input in future. -->
<Setter Property="Padding" Value="{DynamicResource MenuItemPadding}" />
<Setter Property="Template">
@ -369,8 +371,8 @@
</ControlTheme>
<ControlTheme x:Key="{x:Type Menu}" TargetType="Menu">
<Setter Property="Background" Value="Transparent" />
<Setter Property="Menu.ItemContainerTheme" Value="{StaticResource TopLevelMenuItem}" />
<Setter Property="Background" Value="{DynamicResource MenuBackground}" />
<Setter Property="ItemContainerTheme" Value="{StaticResource TopLevelMenuItem}" />
<Setter Property="Template">
<ControlTemplate TargetType="Menu">
<Border

View File

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="MenuFlyoutScrollViewerIconForeground" Opacity="0.6" Color="#F9F9F9" />
<SolidColorBrush x:Key="MenuBackground" Color="Transparent"/>
<!-- MenuFlyout -->
<SolidColorBrush x:Key="MenuFlyoutBackground" Color="#43444A" />
@ -7,7 +8,7 @@
<BoxShadows x:Key="MenuFlyoutBorderBoxShadow">0 0 8 0 #1AFFFFFF</BoxShadows>
<!-- MenuItem -->
<SolidColorBrush x:Key="MenuItemBackground" Color="#43444A" />
<SolidColorBrush x:Key="MenuItemBackground" Color="Transparent" />
<SolidColorBrush x:Key="MenuItemForeground" Color="#F9F9F9" />
<SolidColorBrush x:Key="MenuItemSeparatorBackground" Opacity="0.08" Color="White" />

View File

@ -1,5 +1,6 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="MenuFlyoutScrollViewerIconForeground" Opacity="0.62" Color="#1C1F23" />
<SolidColorBrush x:Key="MenuBackground" Color="Transparent"/>
<!-- MenuFlyout -->
<SolidColorBrush x:Key="MenuFlyoutBackground" Color="White" />
@ -7,7 +8,7 @@
<BoxShadows x:Key="MenuFlyoutBorderBoxShadow">0 0 8 0 #1A000000</BoxShadows>
<!-- MenuItem -->
<SolidColorBrush x:Key="MenuItemBackground" Color="White" />
<SolidColorBrush x:Key="MenuItemBackground" Color="Transparent" />
<SolidColorBrush x:Key="MenuItemForeground" Color="#1C1F23" />
<SolidColorBrush x:Key="MenuItemSeparatorBackground" Opacity="0.08" Color="#1C1F23" />

View File

@ -15,6 +15,8 @@
<!-- MenuItem -->
<Thickness x:Key="MenuItemPadding">16 8</Thickness>
<CornerRadius x:Key="MenuItemCornerRadius">3</CornerRadius>
<x:Double x:Key="MenuItemSeparatorHeight">1</x:Double>
<Thickness x:Key="MenuItemSeparatorMargin">2</Thickness>