Animated ProgressBar WPF in VB.NET

This article defines an animated progressBar in WPF and XAML.
  • 4707

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.



XAML code

<Window x:Class="MainWindow"



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


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

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







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)


        Dim lbl As New Label()

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

        lbl.Content = "Progress"


        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)


    End Sub

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




More Articles

© 2020 DotNetHeaven. All rights reserved.