开发者

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=开发者_如何学Python"23" Background="{x:Null}" Foreground="DarkRed">
        </ProgressBar>
    </Grid>
</Window>

Here's the result:

Wrong Colors in WPF Progress Bar

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

Any thoughts ?


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:

Wrong Colors in WPF Progress Bar

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜