Windows WPF Background Color

By default, the wpf window is white. so what color should I specify for the background, as a result, it will look like a regular window, which, just like .net 2.0, wins the color of application windows. please, help

+4
source share
1 answer

You need to paint the background with the color brush of the system.

SystemColors.ControlBrushKey property will return a ResourceKey for the corresponding SolidColorBrush .

For example, to set the button background, you can 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.DesktopBrushKey}}" Content="Hello, World!" /> </StackPanel> </Page> 
+9
source

Source: https://habr.com/ru/post/1339353/


All Articles