Error visualization not when pressing enter

Sep 24, 2008 at 10:16 PM
Hi

I have a very strange effect. I use a Style for my TextColumns (see below). I have IDataErrorInfo support in my business class.
When I enter an invalid value, the color of the cell changes.
Normally I would expect that the red cross will be showed, no matter how I end the editing.
But when I press ENTER to end the edit, the cross will not be shown.
When I end editing using the mouse (I click somewhere else in the grid, same row or other row, same col or other col), or when I use the TAB key, the cross shows up

Any idea?
Klaus

                  <Style x:Key="TextBoxColumnStyleWorkingCross"
                         TargetType="{x:Type TextBlock}">
                     <Style.Triggers>
                        <Trigger Property="Validation.HasError"
                                 Value="True">
                           <Setter Property="Background"
                                   Value="LightSalmon"></Setter>
                           <Setter Property="ToolTip"
                                   Value="{Binding RelativeSource={RelativeSource Self},Path=(Validation.Errors)[0].ErrorContent}">
                           </Setter>
                        </Trigger>
                     </Style.Triggers>
                     <Setter Property="Validation.ErrorTemplate">
                        <Setter.Value>
                              <ControlTemplate>
                                 <DockPanel LastChildFill="True">
                                 <Grid VerticalAlignment="Center"
                                       Margin="1,0,0,0"
                                       DockPanel.Dock="Right"
                                       >

                                    <Path HorizontalAlignment="Left"
                                          VerticalAlignment="Top"
                                          Width="16.575"
                                          Height="15.013"
                                          Fill="#FFFF0000"
                                          Stretch="Fill"
                                          Data="M2.1923326,13.126918 C2.1923326,13.126918 9.1242888,3.5218058 11.44987,4.1032011 13.775452,4.6845965 11.006801,6.2345933 11.006801,6.2345933 L2.7678984,12.676864 z"
                                          Margin="0,1.221,0,0" />

                                    <Path HorizontalAlignment="Left"
                                          VerticalAlignment="Top"
                                          Width="12.077"
                                          Height="14.755"
                                          Fill="#FFFF0000"
                                          Stretch="Fill"
                                          Data="M4.5860118,1.5306513 C4.1381923,2.7258072 11.531427,12.355297 15.344682,14.995039 17.329125,16.368778 11.249546,6.4430705 10.861957,6.4430705 10.474368,6.4430705 5.1923887,-0.087668306 4.5860118,1.5306513 z"
                                          Margin="2.832,1.183,0,0" />

                                    <Path HorizontalAlignment="Left"
                                          Margin="10.032,2.432,0,0"
                                          VerticalAlignment="Top"
                                          Width="6.52"
                                          Height="5.383"
                                          Fill="#FFAB0404"
                                          Stretch="Fill"
                                          Data="M8.3585482,7.6118008 C8.3585482,7.6118008 9.3829609,6.4793429 10.484053,5.7423106 13.2862,3.8666516 12.129617,5.3933616 12.129617,5.3933616 L8.6703291,8.0523064 z" />

                                    <Path HorizontalAlignment="Left"
                                          Margin="0.287,8.6,0,0"
                                          VerticalAlignment="Top"
                                          Width="8.35"
                                          Height="7.361"
                                          Fill="#FFAB0404"
                                          Stretch="Fill"
                                          Data="M2.9934119,12.280726 C2.9934119,12.280726 5.089625,10.252776 6.167291,9.3225421 7.981912,7.7561752 7.4187557,8.9838185 7.4187557,8.9838185 L2.3691003,12.962527 z" />

                                    <Path HorizontalAlignment="Left"
                                          Margin="2.815,1.686,0,0"
                                          VerticalAlignment="Top"
                                          Width="4.308"
                                          Height="6.059"
                                          Fill="#FFAB0404"
                                          Stretch="Fill"
                                          Data="M9.0912287,5.4815006 C9.0912287,5.4815006 8.3470667,4.9998377 8.3478827,3.5762162 8.3480212,3.3346328 10.995948,6.9120685 10.995948,6.9120685 L10.684377,7.2172575 z" />

                                    <Path HorizontalAlignment="Left"
                                          Margin="7.841,8.657,0,0"
                                          VerticalAlignment="Top"
                                          Width="6.912"
                                          Height="7.304"
                                          Fill="#FFAB0404"
                                          Stretch="Fill"
                                          Data="M11.86076,8.6826086 C11.86076,8.6826086 10.862828,7.9143165 11.929675,7.7667842 12.168981,7.733691 15.684906,12.169333 15.684906,12.169333 L14.649119,11.36494 z" />

                                    <Grid.Triggers>
                                       <EventTrigger RoutedEvent="FrameworkElement.Loaded">
                                          <BeginStoryboard Storyboard="{StaticResource FlashErrorIcon}" />
                                       </EventTrigger>
                                    </Grid.Triggers>
                                 </Grid>
                                 </DockPanel>
                              </ControlTemplate>
                        </Setter.Value>
                     </Setter>
                  </Style>
...
...
                 <toolkit:DataGridTextColumn Header="{StaticResource P.UserName}" ElementStyle="{StaticResource TextBoxColumnStyleWorkingCross}">
                     <toolkit:DataGridTextColumn.DataFieldBinding>
                        <Binding Path="UserName">
                           <Binding.ValidationRules>
                              <DataErrorValidationRule />
                           </Binding.ValidationRules>
                        </Binding>
                     </toolkit:DataGridTextColumn.DataFieldBinding>

Sep 28, 2008 at 3:16 PM
Hi

is this a bug in datagrid?

To summarize: Entering invalid data does bring up the visualization when field is left using TAB key or mouse click, DOES NOT WORK when left using ENTER key

Regards
Klaus
Coordinator
Oct 1, 2008 at 3:14 PM
This is a bug and will be address in the v1 release.