Skip to content
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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

jsuarezruiz
Copy link
Contributor

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 to IMenuElement

LogicalChildrenInternalBackingStore = new CastingList<Element, IMenuElement>(_menus);

Trying to add the IconImageSource to the LogicalChildrenInternalBackingStore insert a null value because this casting

_list.Add(item as TFrom);
fails, cannot convert from Element to IMenuElement.

This PR apply changes to allow Element in the LogicalChildrenInternalBackingStore collection from MenuFlyoutSubItem.

Issues Fixed

Fixes #25893

Copy link
Member

@PureWeen PureWeen left a 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?

@jsuarezruiz jsuarezruiz marked this pull request as draft November 21, 2024 16:09
@PureWeen PureWeen assigned PureWeen and unassigned Foda Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Changes Requested
Development

Successfully merging this pull request may close these issues.

Setting MenuFlyoutSubItem IconImageSource throws a NullReferenceException
3 participants