This project is read-only.

Datagrid Validation ErrorTemplate

Jan 19, 2014 at 9:43 PM
Does anyone have error validation templates styles for the mui datagrid ie styles for the DataGridCell, DataGridRow, etc.

Here's a style I attempted for a DataGridTextColumn validation
<Style TargetType="{x:Type DataGridCell}" BasedOn="{x:Null}" >
          <Setter Property="Padding" Value="-2"/>
                        <Setter Property="Validation.ErrorTemplate">
                            <Setter.Value>
                                <ControlTemplate>
                                    <DockPanel>
                                        <Popup IsOpen="True" Placement="Left" PlacementTarget="{Binding ElementName=ErrorControl}">

                                            <Border BorderThickness="1" Background="LightYellow" BorderBrush="Black" CornerRadius="3" DockPanel.Dock="Left">
                                                <TextBlock
              Text="{Binding ElementName=ErrorControl,Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"
              Height="Auto" Width="Auto">
                                                </TextBlock>
                                            </Border>

                                        </Popup>
                                        <AdornedElementPlaceholder Name="ErrorControl"/>
                                    </DockPanel>
                                </ControlTemplate>
                            </Setter.Value>
                        </Setter>
                        <Style.Triggers>
                            <Trigger Property="Validation.HasError" Value="true">
                                <Setter Property="Foreground" Value="Red"/>
                                <Setter Property="Background" Value="MistyRose"/>
                                <Setter Property="BorderBrush" Value="Red"/>
                                <Setter Property="BorderThickness" Value="1.0"/>
                                <Setter Property="VerticalContentAlignment" Value="Center"/>
                                <Setter Property="ToolTip" 
        Value="{Binding RelativeSource={RelativeSource Self},
        Path=(Validation.Errors)[0].ErrorContent}"/>
                            </Trigger>
                        </Style.Triggers>
                    </Style>

But no luck..

Regards
PrakashZa