Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF windows background color

Tags:

wpf

by default wpf window having white color. so what color i should specify for background as a result it will look like normal window which is just like .net 2.0 win apps windows color. please help

like image 757
Thomas Avatar asked Feb 11 '11 11:02

Thomas


People also ask

How to change Background color in WPF?

Navigate to the Properties window, and click the Background drop-down arrow, and choose Red or another color in the color picker.

How do I change the background color in Visual Studio?

Here's how to change it to a different color theme. On the menu bar, select Tools > Options. In the options list, select Environment > General. In the Color theme list, choose between the default Dark theme, the Blue theme, the Blue (Extra Contrast) theme, and the Light theme.


1 Answers

You need to paint the background using a system color brush.

The SystemColors.ControlBrushKey property will return the ResourceKey for the appropriate SolidColorBrush.

For example, to set the background of a button, you might use the following code:

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  WindowTitle="SystemColors Example" Background="White">  
  <StackPanel Margin="20">
    <Button 
      Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}" 
      Content="Hello, World!" />
  </StackPanel>
</Page>
like image 130
Cody Gray Avatar answered Oct 27 '22 23:10

Cody Gray