views:

32

answers:

0

Hi,

I have a WPF DataGrid With a Text Column. DataGrid is binded with a LIST<> and DataGridText Column is binded with a String Property but the value in this property can be only Numeric. But the Numeric validation on the DataGridTextColumn can't happen with the String value. So i have converted the value from String to Integer using a converter (valueConverter). To validate the data in the DataGridTextColumn, I have used ValidatesOnExceptions=True. But Still validation is not working in the DataGrid.

You can take the sample solution from this path Please check for the last column in the DataGrid (HightTempConverter).

Note: I don't want to use ValidationRules as it very simple validation. I have five string properties which needs to be validated with different datatypes so I can't convert seperate classes for each rule. But I can manage all the convertion in one class.

Hope my requirement is clear. If any clarification then please let me know.

Thanks in Advance!

<DataGridTextColumn  
    ....                 
    Binding="{Binding Path=HightTempConverter, 
        Converter={StaticResource valueConverter},  
        ValidatesOnExceptions=True, ValidatesOnDataErrors=True}" 
                               />