Browse Source

Replace fluent menu item icon presenter with a control theme (#13964)

pull/13989/head
Emmanuel Hansen 3 years ago
committed by GitHub
parent
commit
bfe1a7b4dc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 33
      src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml

33
src/Avalonia.Themes.Fluent/Controls/MenuItem.xaml

@ -81,15 +81,11 @@
SharedSizeGroup="MenuItemChevron" />
</Grid.ColumnDefinitions>
<Viewbox Name="PART_IconPresenter"
Margin="{DynamicResource MenuIconPresenterMargin}"
StretchDirection="DownOnly"
HorizontalAlignment="Center"
VerticalAlignment="Center"
IsVisible="False"
Width="16" Height="16">
<ContentPresenter Content="{TemplateBinding Icon}"/>
</Viewbox>
<ContentControl x:Name="PART_IconPresenter"
Theme="{StaticResource FluentMenuItemIconTheme}"
Content="{TemplateBinding Icon}"
IsVisible="False"
Margin="{DynamicResource MenuIconPresenterMargin}" />
<ContentPresenter Name="PART_HeaderPresenter"
Content="{TemplateBinding Header}"
@ -143,7 +139,7 @@
</ControlTemplate>
</Setter>
<Style Selector="^:icon /template/ Viewbox#PART_IconPresenter">
<Style Selector="^:icon /template/ ContentControl#PART_IconPresenter">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^:selected">
@ -210,4 +206,21 @@
<Setter Property="Padding" Value="{DynamicResource HorizontalMenuFlyoutItemThemePaddingNarrow}" />
<Setter Property="Margin" Value="{DynamicResource HorizontalMenuFlyoutItemMargin}" />
</ControlTheme>
<ControlTheme x:Key="FluentMenuItemIconTheme"
TargetType="ContentControl">
<Setter Property="Width"
Value="16" />
<Setter Property="Height"
Value="16" />
<Setter Property="Template">
<ControlTemplate>
<Viewbox
StretchDirection="DownOnly"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<ContentPresenter x:Name="PART_ContentPresenter" Content="{TemplateBinding Content}" />
</Viewbox>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

Loading…
Cancel
Save