Follow these simple steps to create separate resource files and reference them in the application:
- As we want to create a separate resource file, we need to create a file of type Resource Dictionary. Inside the Solution Explorer, right-click on the project node and create a new folder named Themes.
- Now right-click on the Themes folder and select Add | Resource Dictionary... from the context menu entry:
- In the Add New Item dialog, make sure that the Resource Dictionary (WPF) template is selected. Name it Brushes.xaml, and click Add:
- From the Solution Explorer, open the newly created file Brushes.xaml and add the following LinearGradientBrush inside the ResourceDictionary element with a x:Key name of myLinearBrush. You can add multiple elements inside the ResourceDictionary to have a resource collection. Make sure you assign a unique key name to each one of them:
<LinearGradientBrush x:Key="myLinearBrush"> <GradientStop Offset="0"...