Firing a DataTrigger when specified item is in a collection

First, I'll describe what I'm trying to do, in case I'm going about this the wrong way:

I have a list of objects coming out of my data layer. I want to pass these through a "validation" class (In quotes, since it's not really doing validation, it has the business rules that determine if the item needs user action, which affects the display). Out of this validation logic, I get a list of fields on the object that are in violation of the business rules. I then need to display those fields differently within a WPF GridView.

Originally, the business rules were hard coded into the object, with a the object having fields in a pattern along the lines of Field1, Field1Valid, with the Valid variant doing the check when accessed, which worked for the initial limited case. The view then had a DataTriger that acted on the Field1Valid field to apply the display styling.

Now, with a requirements change, the values within the rules can be different, e.g.: for one setting it might be "Invalid if the value is > 100", but another might have "Invalid if the value is greater than > 90". So, to accommodate this without making my data objects too dirty, these rules are pulled out into a different class that somewhat acts as a visitor. Then I was planning on either returning a dictionary mapping the data objects to a list of invalid fields, represented as just strings, or have a list within the data object containing the list of fields, also as strings.


So, based on this, I'm trying to figure out how to wire up a DataTrigger that will fire if it sees the value "Field1" within the collection of errors, be it on the object itself, or along side of it.

If there is a better method of doing this overall, I'm open to that too.


Perhaps, using binding converter in DataTrigger would be the best way to go about this. You can pass the colletion and make all the checks in the converter itself; apply the styles on the basis of value returned from converter (true for valid and false for invalid). DataTrigger is quiet flexbile and perhaps for a more complex scenario, you can use MuultiBinding with DataTrigger.

Need Your Help

Removing one category from wordpress posts

php wordpress wp-list-categories

Well firstly I am horrible with php. This is my code

clang - build with default flags

clang clang++ llvm-clang

I want to use clang for cross compiling. I've found out that it seems very easy, I can specify architectures/includes etc. just as I invoke clang directly. However, I don't want to keep passing t...