I blog about development using .net, C#, SQL, Windows RT, and other Microsoft technologies.
Disclaimer: All posts are provided "AS IS" with no warranties, confering no rights, and expressing only my personal opinion, not Microsoft's.
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>
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