7

EDIT: I solved my issue...take a look at my answer. Correct if it's wrong. Thanks.

Question: For some reason it seems that the progress bar in a WPF app isn't showing the color I require.

Here's the XAML code:

<Window x:Class="TaskbarProgressApp.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Window.TaskbarItemInfo>
        <TaskbarItemInfo />
    </Window.TaskbarItemInfo>
    <Grid>
        <ProgressBar x:Name="ProgressBar"
                     Margin="10"
                     HorizontalAlignment="Stretch"
                     VerticalAlignment="Center"
                     Height="23" Background="{x:Null}" Foreground="DarkRed">
        </ProgressBar>
    </Grid>
</Window>

Here's the result:

enter image description here

Doesn't look like Dark Red to me...happens to every color :(

Any thoughts ?

Anon
  • 173
  • 2
  • 9
  • 1
    possible duplicate of [WPF: Progressbar foreground color](http://stackoverflow.com/questions/4734814/wpf-progressbar-foreground-color) – Merlyn Morgan-Graham Sep 01 '11 at 04:47
  • You might want to [edit the template from Expression Blend](http://www.microsoft.com/expression/products/blend_overview.aspx) if you have it. – Merlyn Morgan-Graham Sep 01 '11 at 04:47
  • Sorry for being such a noob but how do I edit/use the control templates ?? I don't have Expression Blend. – Anon Sep 01 '11 at 05:58
  • You can create, edit, and use control templates without it. It just provides convenient features to look at the existing control templates that are automatically applied. There is also a free tool for a similar purpose [described on this page, called Dump Control Template](http://www.simple-talk.com/dotnet/.net-tools/essential-tools-for-the-wpf-novice/). – Merlyn Morgan-Graham Sep 01 '11 at 06:40
  • I solved my problem. Posted the answer. – Anon Sep 10 '11 at 02:07

2 Answers2

5

Thanks to @Merlyn Morgan-Graham and @CharithJ for pointing out the other question, I thought it was a different one when I read it.

I solved the problem and I wanted to share it.

I downloaded the Trial of MS Expression Blend and changed:

<Trigger Property="IsIndeterminate" Value="false">
    <Setter Property="Background" TargetName="Animation" Value="#80B5FFA9"/>
</Trigger>

To

<Trigger Property="IsIndeterminate" Value="false">
    <Setter Property="Background" TargetName="Animation" Value="#00000000"/>
</Trigger>

This gives the colors as they are:

Dark Red:

enter image description here

Even this works

<Trigger Property="IsIndeterminate" Value="true">
    <Setter Property="Background" TargetName="Animation" Value="#80B5FFA9"/>
</Trigger>

Doesn't change the progress bar but the colors are as they should be.

It's sad that there is no option to change it directly.

Thanks for the help.

Anon
  • 173
  • 2
  • 9
4

You can do this by changing the control template. Here is an article on that from MSDN. ProgressBar ControlTemplate Example

Here is another similar thread.

Community
  • 1
  • 1
CharithJ
  • 46,289
  • 20
  • 116
  • 131
  • Thanks, but can you point out what exactly is going on with the colors ? I'm quite new at WPF so would like to know more. – Anon Sep 01 '11 at 03:56
  • @ Anon : I know that this can be done by using ComtrolTemplates. But cannot remember the exact steps. I also will have to go through the msdn examples. – CharithJ Sep 01 '11 at 04:17