How do you show progress when IsIndeterminate="True" in a WPF progress bar?

Apparently in some environments Height has to be set explicitly for indeterminate animation to run, while on others it is not needed.


If you set IsIndeterminate to True, the progress has the meaning that something is in progress but you cannot determine the exact duration. So, I can only tell you to set it to false and to use the progress bar in its "standard" behavior.


Simply put if you are trying to make the progress bar start, but as an indeterminate bar, then you must set the property IsIndeterminate to true when ready and to false when finished.

So in other words:

pbar.IsIndeterminate = true; //This starts your bar's animation
pbar.IsIndeterminate = false; //This stops your bar's animation

To give you context as to why you would want to do it this way look at the following psuedo code:

//Some method that is going to start something that is going to take a while
public void StartLongRunningProcess()
{
    //Make a call to a web service asynchronously etc...

    //Start the animation for your progress bar
    pbar.IsIndeterminate = true;
}

//The method (delegate) that handles the result, usually from an event.
//This method will handle the result of the asynchronous call 
public void HandlerForLongRunningProcess()
{
    //Do stuff with result from your asynchronous web service call etc...

    //Stop the animation for your progress bar
    pbar.IsIndeterminate = false;
}

Let me be the first to say that I am not sure if this is the intended usage of this property, but I can say it definitely works.


A possible workaround of the problem is to simply show or hide the ProgressBar control:

progressBar.Visibility = Visibility.Visible;

progressBar.Visibility = Visibility.Collapsed;