I have an MVVM-based WPF 4 application which uses a ProgressBar to show the percentage completion of a long-running operation.
Dabblernl's answer is robust. Here is a hack (because it relies on the internal name of the element that does the glow, which is an implementation detail and may change in a subsequent version):
void SetGlowVisibility(ProgressBar progressBar, Visibility visibility) {
var anim = progressBar.Template.FindName("Animation", progressBar) as FrameworkElement;
if (anim != null)
anim.Visibility = visibility;
}
If how a ProgressBar
is implemented changes, this hack may stop working.
On the other hand, a solution that completely replaces the XAML and styles may lock-in and fix colours, borders etc. and disable behaviour that might be added to a newer version of the ProgressBar in the future...
Edit: The implementation detail did change. Changed "PART_GlowRect"
to "Animation"
-- the former is used only in aero.normalcolor.xaml
, while the latter is used in more recent aero2.normalcolor.xaml
and aerolite.normalcolor.xaml
too.