TheItemContainerTheme inheritance Behavior #10060
-
In discussion #10018 is answer the Equivalent of ItemsControl.ItemContainerStyle is Menu.ItemContainerTheme but the behavior isn't the same. Considering this WPF example: <Menu ItemsSource="{Binding Columns}">
<Menu.ItemContainerStyle>
<Style TargetType="MenuItem">
<Setter Property="Header" Value="{Binding Description}"/>
<Setter Property="ItemsSource" Value="{Binding Columns}"/>
</Style>
</Menu.ItemContainerStyle>
</Menu> will produce a result like this: The equivalent in Avalonia would be: <Menu Items="{Binding Columns}">
<Menu.ItemContainerTheme>
<ControlTheme TargetType="MenuItem" x:DataType="l:Column" BasedOn="{StaticResource {x:Type MenuItem}}">
<Setter Property="Header" Value="{Binding Description}"/>
<Setter Property="Items" Value="{Binding Columns}"/>
</ControlTheme>
</Menu.ItemContainerTheme>
</Menu> will produce a result like this: As you can see, other than incorrect styling, submenus do not inherit the ItemContainerTheme. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
In general it can be done with styles, see https://github.com/AvaloniaUI/Documentation/issues/381#issue-1485800924 #3100 (comment) But this difference with WPF indeed looks strange. |
Beta Was this translation helpful? Give feedback.
In general it can be done with styles, see https://github.com/AvaloniaUI/Documentation/issues/381#issue-1485800924 #3100 (comment)
But this difference with WPF indeed looks strange.