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.
In Solution Explorer
, double-click on the App.xaml
file, as shown in the following screenshot:
Add the following markup inside the existing <Application>
element:
<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" /> </LinearGradientBrush> </Application.Resources>
In the MainPage.xaml
file, modify the toolbar StackPanel...