<ProgressBar /> elements in XAML is used to create a progress bar control in WPF. We can use concept of progress bar control when we want to show some background processing or want to show status of large calculating job, then we use concept of progress bar control.
Some properties related with Progress Bar control
- X: Name—x: Name property is used to set a unique identifier to your progress bar control.
- Width—Width property are used to set width of your progress bar control.
- Height—Height property are used to set height of your progress bar control.
- Value—Value property is used to set or get value of progress bar.
- VerticalAlignment—VerticalAlignment property is used to set vertical alignment of your progress bar control.
- HorizontalAlignment—HorizontalAlignment property is used to set horizontal alignment of your progress bar control.
A XAML code snippet represents a Progress Bar control
<ProgressBar Height="25" HorizontalAlignment="Left" Margin="66,113,0,0" Name="progressBar1" VerticalAlignment="Top" Width="379" Value="0" />
Output of the above code snippet is as follows
On the load event of window write the following code to change value of the progress bar.
private void Window_Loaded(object sender, RoutedEventArgs e)
Duration dd = new Duration(new TimeSpan(10)); //creating an object of the duration class.
DoubleAnimation da = new DoubleAnimation(30.0, dd); //Creating an object of the double animation class.
progressBar1.BeginAnimation(ProgressBar.ValueProperty, da); //Begin the animation in progress bar control.
Output of the following code snippet is as follows