Skip to content

[Avalonia.Controls] feature: Remove the need for MenuItem Icon to be a ILogical #19075

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

Merged

Conversation

Doraku
Copy link
Contributor

@Doraku Doraku commented Jun 17, 2025

What does the pull request do?

Allow any type to be used as MenuItem.Icon as it's already of object? type and displayed using a ContentPresenter in various themes/styles.

What is the current behavior?

Currently, if the value is not a ILogical, the pseudo class :icon won't be set and the icon won't be displayed.

What is the updated/expected behavior with this PR?

The pseudo class change now only check weither the value is not null, allowing to display anything as icon and relying on data template for more possibilities.

Fixed issues

Fixes #19063

It seems my ide config cleaned up some white space in the process, tell me if I should only keep the IconChanged part :)

@avaloniaui-bot
Copy link

You can test this PR using the following package version. 12.0.999-cibuild0057085-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@cla-avalonia
Copy link
Collaborator

cla-avalonia commented Jun 17, 2025

  • All contributors have signed the CLA.

@Doraku
Copy link
Contributor Author

Doraku commented Jun 17, 2025

@cla-avalonia agree

@MrJul MrJul added enhancement backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch labels Jun 17, 2025
@MrJul
Copy link
Member

MrJul commented Jun 17, 2025

It seems my ide config cleaned up some white space in the process

No worries. We usually ask to avoid unnecessary reformatting, but trimming white spaces is acceptable.

Copy link
Member

@MrJul MrJul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you for your contribution!
Tested with arbitrary Icon objects, which work as expected.

@MrJul MrJul enabled auto-merge June 17, 2025 16:19
@MrJul MrJul added this pull request to the merge queue Jun 17, 2025
Merged via the queue into AvaloniaUI:master with commit 6e6477d Jun 17, 2025
11 checks passed
MrJul pushed a commit that referenced this pull request Jun 24, 2025
@MrJul MrJul added backported-11.3.x and removed backport-candidate-11.3.x Consider this PR for backporting to 11.3 branch labels Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the need for MenuItem (and problably other places?) Icon to be a ILogical
4 participants