Home > DeveloperSection > Articles > Progress Bar control in WPF

Progress Bar control in WPF


WPF WPF 
Ratings:
0 Comment(s)
 10303  View(s)
Rate this:

Progress Bar control in WPF

<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

<Grid>

        <ProgressBar Height="25" HorizontalAlignment="Left" Margin="66,113,0,0" Name="progressBar1" VerticalAlignment="Top" Width="379" Value="0" />

</Grid>

 

Output of the above code snippet is as follows

Progress Bar control in WPF

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

Progress Bar control in WPF

 


Don't want to miss updates? Please click the below button!

Follow MindStick