forum

Home / DeveloperSection / Forums / WPF Progressbar

WPF Progressbar

Anonymous User270524-Sep-2013

In my WPF application i have to show a progressbar progress with in a timer tick event, which i am writing as below,

System.Windows.Forms.Timer timer;

public MainWindow()

{

    timer = new System.Windows.Forms.Timer();

    timer.Interval = 1000;

    this.timer.Tick += new System.EventHandler(this.timer_Tick);

}

load event as below

private void Window_Loaded(object sender, RoutedEventArgs e)

{

      progressBar1.Minimum = 0;

      progressBar1.Value = DateTime.Now.Second;

      progressBar1.Maximum = 700;

      timer.Start();        

 }

And at last in tick event,

private void timer_Tick(object sender, EventArgs e)

{

    Duration duration = new Duration(TimeSpan.FromSeconds(20));

    //progress bar animation

    System.Windows.Media.Animation.DoubleAnimation doubleanimation = new    System.Windows.Media.Animation.DoubleAnimation(200.0, duration);

    progressBar1.BeginAnimation(ProgressBar.ValueProperty, doubleanimation);

}

When i execute my program progressbar shows the progress for two-three bars and then it stops increment. Later there is no effect in the progress at all. What went wrong in my code. Please help!..


Updated on 24-Sep-2013
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By