Replies: 3 comments 5 replies
-
which theme is that? Simple? If so, check original Styles. I guess it may be this line: |
Beta Was this translation helpful? Give feedback.
0 replies
-
I created simple ControlTemplate based on default MenuItem template from 'Avalonia/src/Avalonia.Themes.Simple/Controls/MenuItem.xaml': <Window.Resources>
<ControlTemplate x:Key="CustomMenuItemTemplate" TargetType="MenuItem">
<Border Name="root"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ContentPresenter Name="PART_HeaderPresenter"
Grid.Column="0"
Margin="{TemplateBinding Padding}"
VerticalAlignment="Center"
Content="{TemplateBinding Header}"
ContentTemplate="{TemplateBinding HeaderTemplate}">
<ContentPresenter.DataTemplates>
<DataTemplate DataType="sys:String">
<AccessText Text="{Binding}" />
</DataTemplate>
</ContentPresenter.DataTemplates>
</ContentPresenter>
</Grid>
</Border>
</ControlTemplate>
</Window.Resources> I can set the template for explicitly defined menu sub-items: <Menu>
<MenuItem Header="Interfaces">
<MenuItem Header="Interface 1" Template="{StaticResource CustomMenuItemTemplate}"/>
<MenuItem Header="Interface 2" Template="{StaticResource CustomMenuItemTemplate}"/>
</MenuItem>
</Menu> But I don't understand how to set template if menu items are set via ItemsSource: <Menu>
<MenuItem Header="Interfaces" ItemsSource="{Binding Interfaces}>
</MenuItem>
</Menu> I tried to set Template using style: <MenuItem Name="" Header="Interfaces" ItemsSource="{Binding Interfaces}">
<MenuItem.Styles>
<Style Selector="MenuItem">
<Setter Property="Template" Value="{StaticResource CustomMenuItemTemplate}"/>
</Style>
</MenuItem.Styles>
</MenuItem> But it didn't help. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I tried it but it not work
Beta Was this translation helpful? Give feedback.
All reactions