【问题标题】:How to change color of Indeterminate ProgressBar in Windows phone如何在 Windows phone 中更改 Indeterminate ProgressBar 的颜色
【发布时间】:2014-10-15 17:34:47
【问题描述】:

如何更改 Windows phone 中 Indeterminate ProgressBar 的颜色? 我尝试将背景和边框画笔设置为 null 并将前景更改为黑色:

<ProgressBar Minimum="0" Maximum="100" IsIndeterminate="True" Foreground="Black" Background="{x:Null}" BorderBrush="{x:Null}"/>

但是当我运行它时,它仍然是蓝色的,因为动画点在屏幕上移动。

【问题讨论】:

  • 已尝试您的代码,它显示黑点。您为哪个版本的 Windows Phone 开发?
  • 我试过我的代码,它仍然显示蓝点。我正在使用 Windows 手机 8.1

标签: windows-phone windows-phone-8.1


【解决方案1】:

您需要更改&lt;Style&gt;

文档大纲>右键进度条>编辑模板->编辑副本

寻找

<Rectangle x:Name="E1" Fill="{ThemeResource ProgressBarIndeterminateForegroundThemeBrush}"/>

将填充更改为您喜欢的任何颜色

对矩形 E2、E3、E4、E5 重复


或者如果你可以覆盖ProgressBarIndeterminateForegroundThemeBrush

在 App.xaml 中,像这样

<Application.Resources>
    <SolidColorBrush x:Key="ProgressBarIndeterminateForegroundThemeBrush" Color="Yellow" />
</Application.Resources>

【讨论】:

  • 谢谢,但是这个方法将整个进度样式复制并粘贴到我的 xaml 文件中。有没有更好的方法让我重载 ProgressBarIndeterminateForegroundThemeBrush 颜色的定义?
  • @hap497 是的,您可以覆盖 App.xaml 中的 ProgressBarIndeterminateForegroundThemeBrush,请参阅更新的解决方案。
  • 覆盖ProgressBarIndeterminateForegroundThemeBrush 将更改应用程序中所有不确定进度条的颜色。我宁愿建议用Fill="{TemplateBinding Foreground}" 替换Fill="{ThemeResource ProgressBarIndeterminateForegroundThemeBrush}",这样你就可以使用Foreground 属性。
猜你喜欢
  • 2011-06-08
  • 1970-01-01
  • 2023-03-31
  • 1970-01-01
  • 1970-01-01
  • 2010-12-01
  • 1970-01-01
  • 1970-01-01
  • 2015-05-21
相关资源
最近更新 更多