Skip to content

Conversation

@tiny-isle
Copy link
Contributor

Adds OnAttachedToVisualTree to ensure _stroke and _geometry are initialized correctly, fixing cases where inherited properties (e.g., Foreground) were not ready during initial load.
image

@dme-compunet
Copy link
Owner

Thank you for your contribution!

Could you please share a code snippet that demonstrates the issue this PR is addressing?

@tiny-isle
Copy link
Contributor Author

Thank you for your reply. I tried to reproduce this issue in a new project, but failed. It's possible that something in my current project is affecting it, but I haven't found the cause yet.

The issue started when I rewrote the control template for ComboBoxItem, replacing the PathIcon with a LucideIcon. I found that the LucideIcon was not working under certain conditions. When debugging with Rider, I observed that the Foreground property had a value when the LucideIcon triggered a Render call, but the stroke was not being created.

Since the Foreground already had a value when the control was attached to the visual tree, I suspect that the Foreground property change event might not have been triggered. Therefore, I added a check for the stroke when the control is attached to the visual tree.
My operation steps involve switching to a different theme, at which point the icon can be rendered normally. However, when the interface is first created and displayed, the icon is not visible.

I have an operation video and a Rider breakpoint video available for reference below.

Finally, I would like to express my sincere gratitude to the author for providing such an excellent and user-friendly icon library.

4dcc000c11f38ae10971e4b59a9595c7.mp4

@dme-compunet
Copy link
Owner

Thank you for your detailed explanation. It’s possible that initializing _stroke in OnPropertyChanged wasn’t the best idea from the start.
By the way, I’ve encountered issues similar to what you described with text rendering before. Which version of Avalonia are you using?

@tiny-isle
Copy link
Contributor Author

Thank you for your detailed analysis.

The Avalonia version I am currently using is 11.3.8

@dme-compunet dme-compunet merged commit 854089f into dme-compunet:master Dec 1, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants