benruehl / adonis-ui

Lightweight UI toolkit for WPF applications offering classic but enhanced windows visuals
https://benruehl.github.io/adonis-ui/
MIT License
1.71k stars 143 forks source link

How do I set accent color to Windows 10 user color? #106

Closed LavamasterYT closed 4 years ago

LavamasterYT commented 4 years ago

So how do I set the accent color to the Windows 10 user color? I know its in the SystemParameters,WindowGlassColor class but trying to access it via XAML doesn't work and hardcoding it doesn't work either. This is what I tried: Color color = new Color { R = SystemParameters.WindowGlassColor.R, G = SystemParameters.WindowGlassColor.G, B = SystemParameters.WindowGlassColor.B, A = 255 }; this.Resources["{x:Static adonisUi:Colors.AccentColor}"] = color;

benruehl commented 4 years ago

I'm not sure about the usage as Color but using it as Brush works fine for me like this:

<SolidColorBrush x:Key="{x:Static adonisUi:Brushes.AccentBrush}" Color="{x:Static SystemParameters.WindowGlassColor}"/>

Place this in your App.xaml as described here: https://benruehl.github.io/adonis-ui/docs/guides/colors-and-brushes/#overriding-colors

If you have to use it as Color you might try one of the approaches listed on this Stackoverflow thread: https://stackoverflow.com/questions/634069/redefine-alias-a-resource-in-wpf

LavamasterYT commented 4 years ago

I'm not sure about the usage as Color but using it as Brush works fine for me like this:


<SolidColorBrush x:Key="{x:Static adonisUi:Brushes.AccentBrush}" Color="{x:Static SystemParameters.WindowGlassColor}"/>

Place this in your App.xaml as described here:

https://benruehl.github.io/adonis-ui/docs/guides/colors-and-brushes/#overriding-colors

If you have to use it as Color you might try one of the approaches listed on this Stackoverflow thread:

https://stackoverflow.com/questions/634069/redefine-alias-a-resource-in-wpf

Well it partially worked. I tried using the SolidColorBrush try and while it did work, it only worked for some elements like the listbox. Stuff like the blue that waves over the button when clicked still isn’t changed and will only change if I edit the color.

LavamasterYT commented 4 years ago

I'm not sure about the usage as Color but using it as Brush works fine for me like this:


<SolidColorBrush x:Key="{x:Static adonisUi:Brushes.AccentBrush}" Color="{x:Static SystemParameters.WindowGlassColor}"/>

Place this in your App.xaml as described here:

https://benruehl.github.io/adonis-ui/docs/guides/colors-and-brushes/#overriding-colors

If you have to use it as Color you might try one of the approaches listed on this Stackoverflow thread:

https://stackoverflow.com/questions/634069/redefine-alias-a-resource-in-wpf

Well it partially worked. I tried using the SolidColorBrush try and while it did work, it only worked for some elements like the listbox. Stuff like the blue that waves over the button when clicked still isn’t changed and will only change if I edit the color.

benruehl commented 4 years ago

That's because those are different brushes. When you look at the list of accent colors / brushes in the docs you can see them.

For the light color theme they currently have the following values by default:

<Color x:Key="{x:Static adonisUi:Colors.AccentColor}">#5080d8</Color>
<Color x:Key="{x:Static adonisUi:Colors.AccentHighlightColor}">#6C9CF6</Color>
<Color x:Key="{x:Static adonisUi:Colors.AccentIntenseHighlightColor}">#85AFFF</Color>
<Color x:Key="{x:Static adonisUi:Colors.AccentIntenseHighlightBorderColor}">#85AFFF</Color>
<Color x:Key="{x:Static adonisUi:Colors.AccentInteractionColor}">#568AE9</Color>
<Color x:Key="{x:Static adonisUi:Colors.AccentInteractionBorderColor}">#568AE9</Color>

Those are all different shades of light blue. They are used when hovering or clicking controls like buttons and list box items. If you assign the Windows accent color only to one of them, the others still remain with their default values. Now you could assign the Windows accent color to all of them but then you will loose all visual feedback when hovering something like the AccentButton (if you use it) which has the accent color as its primary background already.

It's on you whether that's acceptable for you. Alternatively, you could also try to calculate different shades of the Windows accent color dynamically and assign them to the different brushes.

If you want to get a better feel for the colors and brushes of Adonis UI, I suggest you download the demo app which shows them all and also explains a bit how they are meant to be used.

benruehl commented 4 years ago

Closing this because there has not been any activity for a while. Please reopen in case this is still an issue.