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

Open
wants to merge 10 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
@jsuarezruiz
Copy link
Contributor Author

Can you use a unit test here instead of a UI test?

Added both, xlml test and UITest.

@PureWeen PureWeen marked this pull request as ready for review November 25, 2024 15:25
@PureWeen PureWeen added the p/0 Work that we can't release without label Nov 25, 2024
@PureWeen PureWeen modified the milestones: .NET 9 SR1.1, .NET 9 SR2 Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-controls-flyout Flyout p/0 Work that we can't release without platform/windows 🪟 t/bug Something isn't working
Projects
Status: Changes Requested
Development

Successfully merging this pull request may close these issues.

Setting MenuFlyoutSubItem IconImageSource throws a NullReferenceException
5 participants