-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Open
Labels
Description
Describe the bug
I see code such as the following:
Avalonia/src/Avalonia.Controls/CommandBar/AppBarToggleButton.cs
Lines 108 to 118 in 093976c
| private void UpdateIconForeground() | |
| { | |
| if (Icon is IconElement icon) | |
| { | |
| var fg = Foreground; | |
| if (fg != null) | |
| icon.SetValue(ForegroundProperty, fg); | |
| else | |
| icon.ClearValue(ForegroundProperty); | |
| } |
This is a code smell and indicates something is incorrect with the way icons are being handled. Most of it comes from an incomplete IconElement implementation in Avalonia itself.
To Reproduce
See code:
Avalonia/src/Avalonia.Controls/CommandBar/AppBarButton.cs
Lines 106 to 117 in 093976c
| private void UpdateIconForeground() | |
| { | |
| if (Icon is IconElement icon) | |
| { | |
| var fg = Foreground; | |
| if (fg != null) | |
| icon.SetValue(ForegroundProperty, fg); | |
| else | |
| icon.ClearValue(ForegroundProperty); | |
| } | |
| } |
Avalonia/src/Avalonia.Controls/CommandBar/AppBarToggleButton.cs
Lines 108 to 118 in 093976c
| private void UpdateIconForeground() | |
| { | |
| if (Icon is IconElement icon) | |
| { | |
| var fg = Foreground; | |
| if (fg != null) | |
| icon.SetValue(ForegroundProperty, fg); | |
| else | |
| icon.ClearValue(ForegroundProperty); | |
| } |
Expected behavior
Foreground should be properly inherited without code-behind and be fully integrated with the Avalonia styling system.
Avalonia version
12.0 rc1
OS
No response
Additional context
No response
Reactions are currently unavailable