Progressbar foreground color

Does anybody know how to change the foreground color of a WPF-Progressbar. It always seems to be merged with green.


Solution 1:

just try with this

   <ProgressBar Height="25" IsIndeterminate="True" Width="150" Foreground="Red" ></ProgressBar>

If it is not working as you required you have to modify the Style or ControlTemplate of Progressbar.

To do that you can use Expression Blend from Microsoft or you can get a copy the existing template and modify it.

Solution 2:

Unfortunately, it is hard coded in default style:

<Trigger Property="IsIndeterminate"
     Value="false">
<Setter TargetName="Animation"
    Property="Background"
    Value="#80B5FFA9"/>

You can create your own style from original XAML or try to override background in the Loaded event for example:

private void ProgressBar_Loaded(object sender, RoutedEventArgs e)
{
    var p = (ProgressBar)sender;
    p.ApplyTemplate();

    ((Panel)p.Template.FindName("Animation", p)).Background = Brushes.Red;
}

but it's unreliable