I have a DataGrid with a Column that is binded with an 'int' type property. I am using IDataErrorInfo for validation. My validation rules are working fine they get fired as soon as I change value of a cell. Let's say user enter value less than 0, I show respective error in the tooltip. Problem comes when user clear the value of text box. In that case IDataErrorInfo never fires and as a result I cannot show user validation error through tooltip saying that value cannot be empty. DataGrid makes the red border around textbox, which is fine, and a '!' sign at row header, but no validation error in the tooltip as IDataErrorInfo never got fired. Is there anything I can do to fire IDataError info in case value of textbox is cleared?
Edit:
XAML
<DataGridTemplateColumn>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding DisplayOrder, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding DisplayOrder, UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>
DisplayOrder Property
public int DisplayOrder
{
get
{
return m_DisplayOrder;
}
set
{
if(value != m_DisplayOrder)
{
m_DisplayOrder = value;
OnPropertyChanged("DisplayOrder");
}
}
}