简体   繁体   中英

WPF Change or Override Default System Colors

I researched this in this site and others for a long time, but came empty.

IDE : VS2022 . OS : Windows 11 . App : WPF .NET 6 (core) C# T-SQL

I'm trying to change the default blue system colors in a ResourceDictionary .

I can successfully change all text colors using this XAML code in the resource dictionary:

<SolidColorBrush x:Key="{x:Static SystemColors.ControlTextBrushKey}" Color="Red" />

I want to change all the default blue colors to red, like the border color when hovering a TextBox , a ComboBox , and a PasswordBox , plus the highlight color of all controls.

I can do so using Style s, but this will require me to change the Style of all controls.

Is there an easier way to do so like changing or overriding the system colors?

Is there an easier way to do so like changing or overriding the system colors?

No, not really.

Each control has its own default style and template that may or may not use the system colours. It differs from case to case so you may need to define a custom style or template for each control that you want to modify the appearance of.

There is no such thing as one "default blue colour" in WPF.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM