Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net WPF进度条中的颜色错误_.net_Wpf_Progress Bar - Fatal编程技术网

.net WPF进度条中的颜色错误

.net WPF进度条中的颜色错误,.net,wpf,progress-bar,.net,Wpf,Progress Bar,编辑:我解决了我的问题…看看我的答案。如果是错的,就纠正。谢谢 问题:出于某种原因,WPF应用程序中的进度条似乎没有显示我需要的颜色 以下是XAML代码: <Window x:Class="TaskbarProgressApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/w

编辑:我解决了我的问题…看看我的答案。如果是错的,就纠正。谢谢

问题:出于某种原因,WPF应用程序中的进度条似乎没有显示我需要的颜色

以下是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>

结果如下:

在我看来不是深红色…每种颜色都有:(


有什么想法吗?

您可以通过更改控件模板来实现这一点。下面是MSDN中的一篇文章


是另一个类似的问题。

多亏@Merlyn Morgan Graham和@CharithJ指出了另一个问题,当我读到它时,我认为这是一个不同的问题

我解决了这个问题,我想与大家分享

我下载了MS Expression Blend试用版并更改了:

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


这会使颜色保持原样:

深红色:

即使这样也行

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

不会更改进度条,但颜色与应有的颜色相同

遗憾的是,没有直接改变它的选择


谢谢你的帮助。

谢谢,但是你能指出颜色到底是怎么回事吗?我在WPF是个新手,所以想知道更多。@Anon:我知道这可以通过使用ComtrolTemplates来完成。但是我记不起确切的步骤。我还必须看一下msdn示例。如果你有可能会重复你的示例很抱歉,我是一个傻瓜,但我如何编辑/使用控制模板?我没有Expression Blend。你可以创建、编辑和使用控制模板,而不需要它。它只是提供了方便的功能,可以查看自动应用的现有控制模板。还有一个用于类似目的的免费工具。我解决了我的问题莱姆,把答案贴出来了。
<Trigger Property="IsIndeterminate" Value="true">
    <Setter Property="Background" TargetName="Animation" Value="#80B5FFA9"/>
</Trigger>