0

I have multiple textboxes in my application. I would like to change the border of the textboxes to green or blue depending on the number the user has entered.

I can bind the values of a text box and use IValueConverter to convert double to color. This works fine.

The problem is that I have multiple textboxes with different conditions. Is there a way to define a general conversion function and specify the conditions elsewhere? What I have in mind is a boolean variable that changes depending on the value of each textbox. This variable can then be used for the conversion of the textbox border color.

dexterbla
  • 21
  • 4
  • you should probably include some code for reference purposes; but ,yes, it's possible - in the sense that you can use delegates (Func or Action) on a collection, where the collection is `Controls.OfType().Where(Func)`.. you're essentially just enumerating over instances that satisfy a condition from a 'previous' enumeration (though, in this manner, it may be optimized to not actually perform two iterations over a collection).. – Brett Caswell Nov 11 '15 at 23:42

1 Answers1

0

You could use IMultiValueConverter with the compare operator (maybe as string) for the Converter 'Parameter' and a fixed Value as one of the bindings. Have a look at

How can I pass a constant value for 1 binding in multi-binding?

how to pass constant value for Binding.

Community
  • 1
  • 1
Daniel
  • 191
  • 1
  • 5