C# WPF set system color to button

I want to change the background color of button to system color. Just like I am changing the button color

button2.Background = Brushes.Blue; 

to blue. But no I want to Change the color to system color.


You can get system color from System.Windows.SystemColors

button2.Background = System.Windows.SystemColors.MenuHighlightBrush;

WPF Background is of type System.Windows.Media.Brush. You can set another color like this:

// using System.Windows.Media;

button2.Background = Brushes.White;

button2.Background = new SolidColorBrush(Color.White);

button2.Background = new SolidColorBrush(Color.FromArgb(0xFF, 0xFF, 0, 0);

Background is of type Brush. But you can create a solid brush out of the system color and use that.

SolidBrush systemColorBrush = new SolidBrush(systemColor); // Create SolidBrush from color
button2.Background = systemColorBrush;

You can try something like:

button2.Background = SystemColors.ActiveCaptionBrush;

SystemColors belong to the System.Windows namespace.

I Hope this helps

      Background="{DynamicResource {x:Static SystemColors.DesktopBrushKey}}" 
      Content="Hello, World!" />

Need Your Help

Where to get the latest ANSI C standard document

c ansi

Where can I find the latest ANSI C standard document?

DOM XML in PHP 5.6

php xml dom suse

I am processing XML files in PHP 5.6 running in SUSE 11, which glic library is version 2.11. However, the RPM of PHP 5.6 DOM requires glibc library version 2.14.