Validation in DataGridTemplateColumn

May 14, 2009 at 2:55 PM

I am trying to use a DataGridTemplateColumn.  I am doing validation on the name that the user enters in the editor by throwing exceptions from my item model.  I have done this before in a DataGridTextColumn and the editor there behaves as I expect: textbox gets a red border and stays visible (although tab moves current cell but enter does not).  The problem I am having is that the CellEditingTemplate is being replaced with the CellTemplate as if the validation did not fail.

Here is the xaml for the template column:

<tk:DataGridTemplateColumn x:Name="NameColumn" Header="Name" Width="150" MinWidth="20" SortMemberPath="Name">
         <TextBlock Text="{Binding Name}"/>
         <TextBox x:Name="NameText" Text="{Binding Name, ValidatesOnExceptions=True}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Loaded="TextBox_Loaded" BorderThickness="0" Padding="1"/>