Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wpf C# retrieving accent color windows 10

Tags:

c#

colors

wpf

Yes, WPF.

How to retrieve accent color that the user has chosen in Windows settings into a desktop WPF application?

for example for a Button?

like image 298
foxtrotflynn Avatar asked Apr 03 '16 06:04

foxtrotflynn


People also ask

Is WPF and C# same?

C# is a programming language. WPF is a technology used to develop rich GUI applications using C# (or any other . NET language).

Is WPF still relevant 2022?

“WPF would be dead in 2022 because Microsoft doesn't need to be promoting non-mobile and non-cloud technology. But WPF might be alive in that sense if it's the best solution for fulfilling specific customer needs today. Therefore, having a hefty desktop application needs to run on Windows 7 PCs with IE 8.

Is WPF part of C#?

WPF is used to build Windows client applications that run on Windows operating system. WPF uses XAML as its frontend language and C# as its backend languages. WPF was introduced as a part of . NET Framework 3.0 as the Windows library to build Windows client apps and the next generation of Windows Forms.

What is WPF in C# used for?

Windows Presentation Foundation is a UI framework that creates desktop client applications. The WPF development platform supports a broad set of application development features, including an application model, resources, controls, graphics, layout, data binding, documents, and security.


2 Answers

I'm not sure which version of .Net you're using, but if you're using 4.5 or higher, you can use the SystemParameters class. I think the property you more than likely are after is the WindowsGlassBrush.

this.Background = SystemParameters.WindowGlassBrush;

Note though, that the properties in this class are marked with SecurityCriticalAttribute, so you will more than likely need full trust to access them.

like image 109
Richard Preziosi Avatar answered Oct 13 '22 23:10

Richard Preziosi


I wanted the XAML version of Richard Preziosi answer, that would be :

BorderBrush="{Binding Source={x:Static SystemParameters.WindowGlassBrush}}"
like image 25
leikür Avatar answered Oct 13 '22 21:10

leikür