Search code examples
c#wpfprogress-barsystemcolorssystem.windows.media

Default foreground color of ProgressBar


I've been changing the foreground color of the ProgressBar control from my C# code using the Brush and Brushes classes from the System.Windows.Media library. However, I'm wondering if .Net provides access to the original default foreground color of the ProgressBar for when I want to revert back.

Example:

enter image description here

Right now I'm referencing an answer provided by @Beauty on this question that uses the SystemColors class. SystemColors seems to be the .Net class that provides the default brush colors of controls, but I don't see a brush for the foreground of a Progressbar. Is this color obtainable in SystemColors, or is there some other way of getting it?

An example of how I am changing colors:

XAML:

<ProgressBar Name="Progress" Foreground="{Binding LoadScreenModel.BarColor}" />

C#:

private Brush _barColor = Brushes.Red;

public Brush BarColor
{
    get { return _barColor; }
    set
    {
        _barColor = value;
        NotifyPropertyChange(() => BarColor);
    }
}

Solution

  • The default style for the ProgressBar control (found on this question and you can get it on MSDN) reveals that the foreground color by default is:

    #FF01D328

    That may well match up with a system color, but otherwise just use that.