Replies: 3 comments 11 replies
-
Try something like the following. This ("DefaultForeground") is a resource that is defined in my App.axaml. One for each custom theme. I find that this works for my use case. Maybe it will for yours. (Disclaimer, I'm not on the Avalonia team. Just happened by while reviewing discussions.)
|
Beta Was this translation helpful? Give feedback.
-
You can use PlatformSettings.GetColorValues() to get System accent colors. Which might or might not be the color used by the specific theme. https://docs.avaloniaui.net/docs/concepts/services/platform-settings#getcolorvalues |
Beta Was this translation helpful? Give feedback.
-
I just came across a similar problem and wanted to share my solution. I am a total Avalonia and C# beginner myself, so this may not be the best way of doing it. I needed to get a current Fluent Theme color that is defined in a color palette in my App.axaml like this:
I came up with this helper function (which also converts it to a SKColor, but you may also directly return the Avalonia.Media.Color):
And I am using it like this:
Let me know what you think :) |
Beta Was this translation helpful? Give feedback.
-
I'm using https://github.com/AvaloniaCommunity/Notification.Avalonia to show notifications, but it requires manually specifying the accent color programmatically. I can't seem to find any documentation on how to get the accent color from the current Avalonia theme. Have found random bits of code in various discussion threads, mostly for how to set colors, but can't seem to piece together how to reliably fetch them. A couple related threads:
#12042
#13065
Thanks for any help in advance
Beta Was this translation helpful? Give feedback.
All reactions