Creating the style of a control
Styles provide you with a convenient way to group a set of properties and triggers within a single object and apply it to the elements. You can do this selectively to a set of controls, or you can apply it to all the controls automatically, based on the control type.
In this recipe, we'll begin with the default style of a button and set its various style properties to give it a new look. We will then apply it selectively to set the style of multiple button controls.
Getting ready
Let's get started by creating a new project called CH06.ControlStyleDemo
. Make sure you create the project based on the WPF application template.
How to do it...
In this recipe, we will get started by creating two buttons inside the application window. Then we will create a style for the button and apply it to both of the controls. Follow these steps to try it on your own:
- From the
Solution Explorer
, open theMainWindow.xaml
and replace the existingGrid
panel by aStackPanel
. - Set the
Orientation...