Using resources and templates
When building graphical user interfaces, you will often want to use a resource such as a brush to paint the background of controls. These resources can be defined in a single place and shared throughout the app.
Sharing resources
In the Solution Explorer window, double-click on the App.xaml file. Add the following statement to it:
<Application.Resources> <LinearGradientBrush x:Key="rainbow"> <GradientStop Color="Red" Offset="0" /> <GradientStop Color="Orange" Offset="0.1" /> <GradientStop Color="Yellow" Offset="0.3" /> <GradientStop Color="Green" Offset="0.5" /> <GradientStop Color="Blue" Offset="0.7" /> <GradientStop Color="Indigo" Offset="0.9" /> <GradientStop Color="Violet" Offset="1" /> ...