Using IDataErrorInfo with the DataGrid

WPF Studio, Themes, and Shared Library for WPF Forum

Posted 13 years ago by Pat Maneely - Software Engineering Manager, Cobham Aerospace
I'm trying to use Data Validation with the DataGrid without any success. I was wondering if you had any helpful hints or example code. I'm kinda stuck.

My Cell Style is:

<Style x:Key="CenterCellStyle" TargetType="{x:Type toolkit:DataGridCell}">
<Setter Property="TextBlock.TextAlignment" Value="Center"/>
<Trigger Property="Validation.HasError" Value="true">
<Setter Property="ToolTip"
Value="{Binding RelativeSource={x:Static RelativeSource.Self},

My DataGrid XAML is:

<datagrid:ThemedDataGrid Name="KeysDataGrid"
AutoGenerateColumns="False" GridLinesVisibility="All"
SelectionMode="Single" SelectionUnit="FullRow"
ItemsSource="{Binding Keys}"
SelectedIndex="{Binding SelKeyIndex, Mode=TwoWay}"
CellStyle="{StaticResource CenterCellStyle}">


<datagrideditors:DataGridMaskedTextColumn Header="Key" Mask="[0-9A-F]*"
Width="Auto" HeaderStyle="{StaticResource CenterAlignedColumnHeaderStyle}"
Binding="{Binding Key,
ValidatesOnDataErrors=True, UpdateSourceTrigger=PropertyChanged, NotifyOnValidationError=True}">

I know that the DataValidation logic in my view ViewModel is being called and it returns an error string

But the Grid never indicates an error by changing the border red, nor is the Tooltip displayed.

Comments (1)

Posted 13 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Pat,

Our ThemeDataGrid is an extension of the Microsoft DataGrid, and we only support our extensions/themes. General DataGrid questions should be directed to Microsoft or a third-party Q&A site (such as StackOverflow).

If this is directly related our our extensions, please put together a small sample project that reproduces your issue and email it over then we can take a closer look. Be sure to remove any executables or change the extension of the zip file to ensure it gets past our email filters.

Based on what you show above though, the DataGridCell would never have Validation.HasError set to true. As it is not bound to anything, it is simply a container for other controls.

This article describes how to customize cell validation feedback via the TextBox control used by the DataGridTextColumn. The same concepts should be applicable to our MaskedTextBox.

[Modified at 09/20/2011 12:30 PM]

Actipro Software Support

The latest build of this product (v24.1.2) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.