-
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
[Windows] Fix crash setting MenuFlyoutSubItem IconImageSource #26021
base: main
Are you sure you want to change the base?
Conversation
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.
Can you use a unit test here instead of a UI test?
Added both, xlml test and UITest. |
@@ -16,7 +16,12 @@ public partial class MenuFlyoutSubItem : MenuFlyoutItem, IMenuFlyoutSubItem | |||
|
|||
public MenuFlyoutSubItem() | |||
{ | |||
LogicalChildrenInternalBackingStore = new CastingList<Element, IMenuElement>(_menus); |
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 the casting list is a wrapper and if you change the source is is also reflected.
Adding new items to a new list is not going to keep them synced.
Can we use the casting list still and just go to Element?
Description of Change
Fix crash setting
MenuFlyoutSubItem
IconImageSource on Windows.From #24688 the ImageSource is added as logical children of the menu item. However, the
LogicalChildrenInternalBackingStore
collection from MenuFlyoutSubItem does a casting toIMenuElement
maui/src/Controls/src/Core/Menu/MenuFlyoutSubItem.cs
Line 19 in 5b5aaa5
Trying to add the IconImageSource to the LogicalChildrenInternalBackingStore insert a null value because this casting
maui/src/Controls/src/Core/ReadOnlyCastingList.cs
Line 91 in 5b5aaa5
IMenuElement
.This PR apply changes to allow Element in the
LogicalChildrenInternalBackingStore
collection from MenuFlyoutSubItem.Issues Fixed
Fixes #25893