WPF windows background color

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>

Tags:

Wpf