New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(MenuFlyout): Add ItemContainerTheme #10020
feat(MenuFlyout): Add ItemContainerTheme #10020
Conversation
You can test this PR using the following package version. |
if ((element as MenuItem)?.ItemContainerTheme == ItemContainerTheme) | ||
element.ClearValue(ItemContainerThemeProperty); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I understand.
When I set <MenuFlyout ItemContainerTheme="" />
I would expect same container theme to be applied on flyout items and subitems.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you. But I have decided to respect the same behavior of the menus.
Avalonia/src/Avalonia.Controls/Menu.cs
Lines 97 to 105 in 61916d7
protected internal override void PrepareContainerForItemOverride(Control element, object? item, int index) | |
{ | |
base.PrepareContainerForItemOverride(element, item, index); | |
// Child menu items should not inherit the menu's ItemContainerTheme as that is specific | |
// for top-level menu items. | |
if ((element as MenuItem)?.ItemContainerTheme == ItemContainerTheme) | |
element.ClearValue(ItemContainerThemeProperty); | |
} |
I've opened a discussion #10060 about it, but no one has responded yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's different in case of Menu control.
As in Menu control you have top level menu items that are always rendered horizontally and flyout/popup menus with a different styles. And there you wouldn't expect same style to be applied everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally expected the same behavior also for the Menu as it happens in WPF. I'd like to do a PR that changes the behavior of the menus, but I'm waiting for your response first. I don't want invest time unnecessarily.
d0d395c
to
5123f14
Compare
You can test this PR using the following package version. |
What does the pull request do?
Add ItemContainerTheme to MenuFlyout
What is the current behavior?
MenuFlyout has no ItemContainerTheme
What is the updated/expected behavior with this PR?
How was the solution implemented (if it's not obvious)?
Checklist
Breaking changes
Obsoletions / Deprecations
Fixed issues
Fixes #10010
Depend of #10019 Because it depends on the style fix made in issue #10019