Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong Colors in WPF Progress Bar

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 ?

like image 909
Anon Avatar asked Sep 01 '11 03:09

Anon


2 Answers

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.

like image 78
Anon Avatar answered Nov 12 '22 14:11

Anon


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.

like image 32
CharithJ Avatar answered Nov 12 '22 14:11

CharithJ