-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
MenuItem gets updated when IconImageSource changes - Fix 17210 #18119
base: main
Are you sure you want to change the base?
Conversation
Hey there @jm-goldacker! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
The issue mentions "Binding does not work with glyph." This is the corresponding code in the reproduction project: That code will not render the glyph. The problem is the binding. I solved it by referencing the binding source: Is it intended to work like that? |
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.
Thanks for this PR! The fix looks right, but I think the issue you pointed out with the weird binding context may be because we are not properly propagating the context to menu items.
Are you still able to look at this PR? I know it has been a day or year... Let me know. I will try and be more responsive. Back in 2023, things were more crazy - now we got time to look at PRs :P
Some questions for the binding issue:
- Does binding things like text work?
- I wonder if you rebase things will be better - it has been over a year now
- Are you able to add a UI test to verify the menu has changed? This PR has a UI test for menu items that you can reference: [Windows] Fix for MenuFlyoutItems programmatically added to MenuFlyoutSubItems are not visible #26886
Let me know if you still feel like working on this issue.
I had a quick look at a rebase, and saw this conflict: public static readonly BindableProperty IconImageSourceProperty = BindableProperty.Create(nameof(IconImageSource), typeof(ImageSource), typeof(MenuItem), default(ImageSource),
<<<<<<< fix-17210
propertyChanging: OnImageSourceChanging, propertyChanged: OnImageSourceChanged);
=======
propertyChanged: (bindable, oldValue, newValue) =>
{
((MenuItem)bindable).AddRemoveLogicalChildren(oldValue, newValue);
}
);
>>>>>>> main Basically, the code in main now propagates the binding context. I think if you were to rebase, the old bindings would work and the issue would be to just add a UI test. |
Hi, I would indeed like to continue working on this issue. |
Description of Change
I added an event handler method that subscribes to the
SourceChanged
event of theMenuItem
'sIconImageSource
.When this event occurs, subscribers will be notified that the
IconImageSourceProperty
of theMenuItem
changed - so the UI will update.Issues Fixed
Fixes #17210
examples from public reproduction project repository, before swapping icons:

after swapping icons:

The examples can be found in the Maui.Controls.Sample project.