Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Silverlight textbox conditional binding with style

I am binding an int to a textbox. 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.

like image 389
Shawn Mclean Avatar asked Aug 24 '26 15:08

Shawn Mclean


1 Answers

This is where you would use Value Converters, one that converters from an int to a color. You then bind the background property to the int property (as well as binding the text).

Here's an post about them So What’s a Silverlight Value Converter Anyway?

like image 76
Nigel Sampson Avatar answered Aug 26 '26 19:08

Nigel Sampson