WPF DataGrid DataGridTemplateColumn with Validators

J

Jonathan Chapman

I've been searching all over and I can't figure out how to do this so I'm
hoping someone out there knows.

I've added a DataGridTemplateColumn that contains a textbox that limits the
text to numbers.

<DataGridTemplateColumn MaxWidth="50" Header="Port">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding
Path=Port,ValidatesOnDataErrors=True}" />
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
<DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<TextBox Text="{Binding Path=Port,
Converter={StaticResource numericConverter},ValidatesOnDataErrors=True}"
Style="{StaticResource CellEditStyle}"
thirdPartyWPF:TextBoxNumericMaskBehavior.Mask="UnsignedInteger"
thirdPartyWPF:TextBoxNumericMaskBehavior.MaximumValue="9999"
MaxLength="4"></TextBox>
</DataTemplate>
</DataGridTemplateColumn.CellEditingTemplate>
</DataGridTemplateColumn>

I have validators to display a mouse over error message. I have another
column that is a DataGridTextColumn that has validation as well. In the
DataGridTextColumn if there is invalid data the DataGrid prevents me from
going to another column or to create another row. However, my template
column does not prevent me from going to another cell.

How can I replicate the behaviour of the DataGridTextColumn in my
DataGridTemplateColumn?

Thanks,
Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top