Task 1 – Creating a Resource from the Background Property of a Button
For this exercise, you can continue to use the solution from Exercise 2 or open the begin solution located at\Ex03-CreatedAndUsingResources\begin\(Choosing the folder that matches the language of your preference.)You will need to build the solution (click Build | Build Solution) before the designer will show the WPF work we did in Exercise 2.
Open Window1.xaml and select the forwardButton created in Exercise 2.
In the Properties window, use the Search tool to find the Background property.
Setting Background Property
Click the Background property and the Brush editor will appear. Click the eyedropper tool and select a color from anywhere on your screen. You will see the background of the button has changed.
Now click the black square next to background label in the property browser to pick the “Extract to Resource” option.
Extract Value to Resource
Click OK in the Create Resource dialogue, accepting the default values. This window lets you extract the property’s value into a resource that you can re-use. In this case, the resource will be created in Window1.xaml.
Look in the XAML code editor and you’ll find a SolidColorBrush element inside the Window.Resources node.