简体   繁体   English

Silverlight文本框条件绑定样式

[英]Silverlight textbox conditional binding with style

I am binding an int to a textbox. 我将int绑定到文本框。 Is there a way to change the color of the textbox based on the binded value? 有没有办法根据绑定值更改文本框的颜色?

For eg. 例如。 if the int if > 0, the textbox should be green, else, red. 如果int if> 0,则文本框应为绿色,否则为红色。

This is where you would use Value Converters, one that converters from an int to a color. 这是您使用值转换器的地方,它可以从int转换为颜色。 You then bind the background property to the int property (as well as binding the text). 然后,将background属性绑定到int属性(以及绑定文本)。

Here's an post about them So What's a Silverlight Value Converter Anyway? 这是关于他们的帖子那么什么是Silverlight Value Converter呢?

如果您需要更复杂并使用适当的样式,请尝试这样做

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

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