Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How To Override The Default Color Of A ProgressBar In A Windows 8 Application

DZone's Guide to

How To Override The Default Color Of A ProgressBar In A Windows 8 Application

· Mobile Zone
Free Resource

Discover how to focus on operators for Reactive Programming and how they are essential to react to data in your application.  Brought to you in partnership with Wakanda

So you’re doing Windows 8 development and, very likely, your app needs to display some data. Rarely this data is immediately available: maybe you need to download it, or you have to parse it before displaying it. Here comes in help the ProgressBar, so that the user is aware that something is loading and that he needs to wait until the operation is completed.

By default, the ProgressBar automatically uses the accent color the user has selected for his Windows 8 installation: this isn’t always the best choice, because your application may use a background that doesn’t fit with the ProgressBar color.

The first thing you would try to do, as a developer, is to change the Foreground or the Background property of the control, but you’ll notice that the trick doesn’t work: the color of the ProgressBar doesn’t change.

This happens because the default ProgressBar color is defined in one of the default styles, so you have to override it to change it. To do this, simply add the following statement in the ApplicationResources defined in the App.xaml file:

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

In this example, the ProgressBar is displayed with a white color: instead of writing the color’s name, you can also put the hexadecimal code of the color.

Enjoy it!

Learn how divergent branches can appear in your repository and how to better understand why they are called “branches".  Brought to you in partnership with Wakanda

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}