Editing the template of any control
WPF allows you to customize the template of any control. Using Visual Studio, you can easily edit any template to meet your requirements. In this recipe, we will discuss how to edit the template of a ProgressBar
control.
Getting ready
Let's get started with creating a project called CH06.ControlTemplateDemo
. Make sure you select the right WPF application template while creating the project.
How to do it...
Follow these steps to edit the progress bar template:
- Open the
MainWindow.xaml
file and replace the defaultGrid
control with a verticalStackPanel
. - Add two
ProgressBar
controls inside theStackPanel
and set theirHeight
,Width
, andValue
properties, as shared here:
<StackPanel Orientation="Vertical"> <ProgressBar Height="30" Margin="10" Value="40"/> <ProgressBar Height="30" Margin="10" Value="60"/> </StackPanel>
- If you run the application, you will see...