It looks like the bar size is calculated in the private method ProgressBar.SetProgressBarIndicatorLength
. It's only called from OnValueChanged
, OnTrackSizeChanged
, and OnIsIndeterminateChanged
.
You could call SetProgressBarIndicatorLength
through reflection, or cycle one of the properties that causes it to be called. This is lame, but it doesn't look like the ProgressBar
was designed so that the Maximum
and Minimum
would be changed in mid-progress.
Regardless of which method you choose, you can figure out when the Maximum
property changes by using DependencyPropertyDescriptor.AddValueChanged:
DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty(ProgressBar.MaximumProperty, typeof(ProgressBar)));
if (dpd != null)
{
dpd.AddValueChanged(myProgressBar, delegate
{
// handle Maximum changes here
});
}