有没有办法通过绑定到视图模型属性来更改 WPF 进度条的颜色
我想要一个进度条根据当前值当前所在的范围来更改其颜色。我想知道进度条上是否有一个属性,我可以将视图模型属性绑定到该属性来更改颜色。 WPF进度条上是否存在这样的属性?
I'm wanting a progress bar to change it's color depending on the range the current value is currently in. I was wondering if there was an attribute on the progress bar that I could bind a view model property to to change the color. Does such an attribute exist on the WPF progressbar?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需将前景色更改为您喜欢的颜色即可:
编辑(回答您的评论):是的,您需要一个
Brush
属性(几乎所有颜色属性在WPF中都是Brushed)但是别担心,这很简单:
属性:
Just change the foreground color to the color you like:
Edit (answering your comment): Yes, you need a
Brush
property (Almost all color properties are Brushed in WPF)But don't worry it's very simple:
And the property:
您是否尝试更改进度条的整个颜色,或者是否尝试根据值使进度条的不同部分具有不同的颜色?如果是后者,您需要渐变画笔,根据进度栏中的值设置不同的渐变停止点。
Are you trying to change the entire color of the progress bar or are you trying to have different parts of the progress bar be different colors, based on the value? If the latter you'll want a gradient brush, setting different gradient stops according to the values in the progress bar.