WPF Progressbar Stops after a Few Bars

In my WPF application I have ... System.Windows.Forms.Timer timer;

That is the wrong type of timer. Use a DispatcherTimer instead.

When i execute my program progressbar shows the progress for two-three bars and then it stops

This surprises me, I wouldn't have expected it to work at all. This means you may have other problems too, like blocking the main (dispatcher) thread.

You are only setting the Value once, in the Loaded event:

     progressBar1.Value = DateTime.Now.Second;

There is no change to progressBar1.Value in the Tick event. So it figures that it stops moving.


Since your ProgressBar doesn't relate to any particular behavior, it looks like a job for an indeterminate bar.

This other SO question provides some insight about it. In short, it's a XAML one-liner:

<!-- MinVal, MaxVal, Height needed for this to work -->
<ProgressBar x:Name="progressBar1" Margin="5" IsIndeterminate="True" 
    MinimumValue="0" MaximumValue="700" value="0" Height="20"/> 

Then in code, you go like this:

progressBar1.IsIndeterminate = true; // start animation
progressBar1.IsIndeterminate = false; // stop animation