WPF ProgresssBar control in VB.NET

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

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.

Properties

This control has the following properties.

pr1.gif
 

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.


 

pr2.gif 

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.

 

pr3.gif
 

Figure 3.

 

The progressBar control looks like this.


 

pr4.gif 

Figure 4.

 

XAML Code

 

<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.

FlowDirection="RightToLeft"

Adding a ProgressBar to a StatusBar

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

pr5.gif
 

Figure 5.

XAML code

<Window x:Class="MainWindow"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

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

    <Grid>

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

            <StatusBarItem>

<TextBlock>Status:</TextBlock>

</StatusBarItem>

</StatusBar>

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

    </Grid>

</Window>

Categories

More Articles

© 2019 DotNetHeaven. All rights reserved.