Working with the progress bar control
When you perform a lengthy task in the background, you probably would like to add a progress indicator in your application UI to give a visual indication that some work is in progress. WPF provides us with a control name, ProgressBar
, to show a percentage value of the work between 0% to 100%, in general.
In this recipe, we will learn about the progress bar control and its various properties.
Getting ready
Let's open the Visual Studio and create a new WPF application project. Name it CH02.ProgressBarDemo
.
How to do it...
Once the project gets created, follow these steps to add a progress indicator to the application's UI:
- Open the
MainWindow.xaml
, and replace the existingGrid
panel with aStackPanel
, so that, we can add our controls stacked vertically. - As shown in the following code snippet, add three
ProgressBar
controls in theStackPanel
:
<StackPanel Margin="10"> <TextBlock Text="Progress Indicator set at: 20%" /> <ProgressBar Height...