Using user-selected colors and fonts
Sometimes it's useful to use one of the selected colors or fonts the user has chosen in the Windows Control Panel Personalization applet (or the older Display Settings in Windows XP), such as Window caption, Desktop color, and Selection color. Furthermore, an application may want to react dynamically to changes in those values. This can be achieved by accessing special resource keys within the SystemColors
and SystemFonts
classes.
Getting ready
Make sure Visual Studio is up and running. Go to the Control Panel Personalization applet and change the theme to Classic. This will make it easy to see the dynamic changes when colors of fonts change.
How to do it...
We'll create an application that uses some user-selected color and font, and reacts automaticaly to changes in those:
Create a new WPF Application named
CH02.UserSelectedColorsFonts
.Open
MainWindow.xaml
. Add two rows to the grid.Add a
Rectangle
covering the first row and aTextBlock
in the lower row...