We will now build an application that uses system colors and fonts. Follow these steps to proceed with it:
- Open the MainWindow.xaml file and insert the following Rectangle inside the Grid panel:
<Rectangle Height="100" Width="300"/>
- We want to fill the rectangle with the color of the desktop brush. Add the following markup to fill the background color of the rectangle Fill="{DynamicResource {x:Static SystemColors.DesktopBrushKey}}". Now the XAML will look like the following:
<Rectangle Fill="{DynamicResource {x:Static SystemColors.DesktopBrushKey}}" Height="100" Width="300"/>
- Let's run the application now. You will see that a background color for the rectangle has been picked up by the application. This is based on the selection that you have for the DesktopBrush in your system:
- To confirm this, right-click on your desktop and select Personalize. If...