ARTICLE

WPF animated ProgressBar in VB.NET

Posted by Micalgray Articles | XAML in VB.NET March 23, 2011
This article defines an animated progressBar in WPF and XAML.
Download Files:
 
Reader Level:

This article defines an animated progressBar in WPF and XAML.

WPF ProgressBar with animation

In this article we take a Button control to start the ProgressBar and StatusBar control to display the progress With animation and a TextBlock control to add text.

The form looks like the below Figure1.

1.gif

Figure1.gif

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

    <StackPanel>

        <Button Content="Start" Click="MakeOne" Width="189" />

        <StatusBar Name="sbar" Grid.Column="0" Grid.Row="5" VerticalAlignment="Bottom" Background="Beige" >

            <StatusBarItem>

                <TextBlock>StatusBar</TextBlock>

            </StatusBarItem>

        </StatusBar>

    </StackPanel>

</Window>

Now double click on the Button control and add the following code.

Private Sub MakeOne(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)

        sbar.Items.Clear()

        Dim lbl As New Label()

        lbl.Background = New LinearGradientBrush(Colors.Pink, Colors.Red, 90)

        lbl.Content = "Progress"

        sbar.Items.Add(lbl)

        Dim progbar As New ProgressBar()

        progbar.Background = Brushes.Gray

        progbar.Foreground = Brushes.Green

        progbar.Width = 150

        progbar.Height = 15

        Dim duration As New Duration(TimeSpan.FromMilliseconds(2000))

        Dim doubleanimation As New Animation.DoubleAnimation(100.0, duration)

        doubleanimation.RepeatBehavior = New RepeatBehavior(3)

        progbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation)

        sbar.Items.Add(progbar)

    End Sub

Now run the application and click on the button start to start progress.

2.gif

Figure2.gif

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor