Changing the Foreground Color of an Indeterminate ProgressBar

Changing the Foreground Color of an Indeterminate ProgressBar

Rate This
  • Comments 3

You would think that the following XAML changes the indeterminate progress bar’s foreground color:

<ProgressBar IsIndeterminate="True" Foreground="Aquamarine" />

Unfortunately, that doesn’t work. You will need to override the following value in the default theme resource dictionary:

<ResourceDictionary.ThemeDictionaries>
    <ResourceDictionary x:Key="Default">
        <x:String x:Key="ProgressBarIndeterminateForegroundThemeBrush">Aquamarine</x:String>
    </ResourceDictionary>
</ResourceDictionary.ThemeDictionaries>

You can add that override to App.xaml, or to a new resource dictionary that’s merged into App.xaml:

<Application
    x:Class="Sample.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Common/StandardStyles.xaml" />
                <ResourceDictionary Source="Common/CustomStyles.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Application.Resources>
</Application>

CustomStyles.xaml:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <!-- Global Overrides -->
    <ResourceDictionary.ThemeDictionaries>
        <ResourceDictionary x:Key="Default">
            <x:String x:Key="ProgressBarIndeterminateForegroundThemeBrush">Aquamarine</x:String>
        </ResourceDictionary>
    </ResourceDictionary.ThemeDictionaries>
</ResourceDictionary>
Leave a Comment
  • Please add 2 and 7 and type the answer here:
  • Post
  • It looks like a bug and you just have a workaround.

    Any reason for such strange behaviour?

  • Please feel free to file a bug at http://connect.microsoft.com/

  • Nice trick ! Really strange behaviour compared to the ProgressRing

Page 1 of 1 (3 items)