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 the MainWindow.xaml and replace the existing Grid panel by a StackPanel.
- Set the Orientation property of the StackPanel to Vertical, so that we can stack the child controls vertically.
- Now add a few buttons inside it and assign a content. Here's our markup of the StackPanel with two buttons:
<StackPanel Orientation="Vertical" Margin="10"> <Button Content="Click Here"/> <Button Content="Click Here"/> </StackPanel>
- Build and run the application. You will see the following UI:
- Close the application and return to the MainWindow.xaml page. Inside the Window tag, add <Window.Resources></Window.Resources> to add the button style...