本文介绍了进度前景色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有人知道如何更改一个WPF的进度条的前景色。它似乎总是与绿色合并。

Does anybody know how to change the foreground color of a WPF-Progressbar. It always seems to be merged with green.

推荐答案

不幸的是,它在默认样式硬codeD:

Unfortunately, it is hard coded in default style:

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

您可以从原来的XAML创建你自己的风格或试图超越背景的Loaded事件,例如:

You can create your own style from original XAML or try to override background in the Loaded event for example:

private void ProgressBar_Loaded(object sender, RoutedEventArgs e)
{
    var p = (ProgressBar)sender;
    p.ApplyTemplate();

    ((Panel)p.Template.FindName("Animation", p)).Background = Brushes.Red;
}

但它是不可靠的。

but it's unreliable

这篇关于进度前景色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-02 08:52