WPF ProgresssBar control in VB.NET

In this article we will lean how to create and use ProgressBar control in WPF.
  • 1774

In this article we will lean how to use ProgressBar control in WPF.

ProgressBar control

ProgressBar control are used to represents the task progress to the user. The Minimum value couldn't be less than 0 and the Maximum one couldn't be more than 100.


This control has the following properties.


Figure 1.

The Width property represents the width of a ProgressBar. 

The Height property represents the height of a ProgressBar.

The Name property represents the name of the control, which is a unique identifier of a control.  

The Margin property tells the location of a ProgressBar on the parent control.

The HorizontalAlignment and VerticalAlignment properties are used to set horizontal and vertical alignments.

Creating ProgressBar in XAML

<ProgressBar Margin="9,10,0,12" Name="PR1" HorizontalAlignment="Left"

VerticalAlignment="Top" Width="300" Height="30" />


The progressBar control looks like this.



Figure 2.


Using Value property of ProgressBar control


The Value property of ProgressBar sets up the current value of a ProgressBar control. We can set the Value property by property window.



Figure 3.


The progressBar control looks like this.



Figure 4.




<ProgressBar Margin="10,10,0,13" Name="ListView1" HorizontalAlignment="Left"

VerticalAlignment="Top" Width="300" Height="30" Value="50" />


Flow Direction

The FlowDirection property sets the flow of ProgressBar. You can set this value either LeftToRight or RightToLeft. The default value is LeftToRight.


Adding a ProgressBar to a StatusBar

There are many application which see the progressBar control in the Status Bar. The form look like this.


Figure 5.

XAML code

<Window x:Class="MainWindow"



    Title="MainWindow" Height="350" Width="525">


        <StatusBar Name="SBar" Grid.Column="0" Grid.Row="5" VerticalAlignment="Bottom"Background="LightBlue"  >





        <ProgressBar Height="22" HorizontalAlignment="Left" Margin="44,292,0,0"Name="ProgressBar1" VerticalAlignment="Top"
 Width="179" Value="50" />




More Articles

© 2020 DotNetHeaven. All rights reserved.