简体   繁体   English

WPF进度条中的错误颜色

[英]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. 问题:出于某种原因,似乎WPF应用程序中的进度条没有显示我需要的颜色。

Here's the XAML code: 这是XAML代码:

<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: 这是结果:

在此输入图像描述

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. 感谢@Merlyn Morgan-Graham和@CharithJ指出另一个问题,当我读到它时,我认为它是另一个问题。

I solved the problem and I wanted to share it. 我解决了这个问题,我想分享它。

I downloaded the Trial of MS Expression Blend and changed: 我下载了MS Expression Blend的试用版并更改了:

<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: 深红:

在此输入图像描述

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. 这是来自MSDN的一篇文章。 ProgressBar ControlTemplate Example ProgressBar ControlTemplate示例

Here is another similar thread. 是另一个类似的线程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM