Search code examples
c#wpfprogress-bar

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

  • 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