views:

22

answers:

0

We have several data objects in our application that wind up bound to grids. We have them implementing the IDataErrorInfo interface, so that by adding error messages to the properties, we see the rowheader change style and the DataGridCells gain a red border. All well and good.

We now have an additional requirement that rather than merely having Errors, we have Errors and Warnings. Warnings are identical to errors except that they should produce a yellow border instead of a red one.

We created a new interface, IDataWarningInfo, based on IDataErrorInfo. Works fine. I can access it at runtime, I have RowValidatiionRules that that are able to access it, and set the yellow row header instead of the red one, the appropriate tooltip, etc. What I'm missing is the ability to set a given cell's border to yellow, on the basis that it is databound to a property where that property has a warning message.

I could retrieve that warning message by passing the name of the databound property back to the interface; I suspect that under the hood, the Validation code is doing exactly that. What I'm missing is how to do that in XAML. Specifically, I think I need to apply a Style to a cell, where that Style contains a DataTrigger that somehow passes to the object the name of the DataBound property, and then if the result is different from null, applies a few Setters to the Cell.

Does anyone know how to achieve this?