0

I have a DataGridTextColumn and Element Style set tp a type TextBox and i have a validationstyle place for the TextBox which highlights the Cell with Red Border in case of it doesn't have any values. (like a Required Field Validation)

<Style  x:Key="TextBoxValidationStyle" TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
    <Style.Triggers>
        <Trigger Property="Validation.HasError" Value="True">
            <Validation.ErrorTemplate>
                <ControlTemplate>
                    <DockPanel>
                        <Border BorderBrush="Red" BorderThickness="1">
                            <AdornedElementPlaceholder x:Name="controlWithError"/>
                        </Border>
                        <TextBlock Foreground="Red" FontSize="20" FontFamily="Segoe UI" Margin="3,0,0,0" />
                    </DockPanel>
                </ControlTemplate>
            </Validation.ErrorTemplate>
            <Setter Property="ToolTip" Value="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=(Validation.Errors)[0].ErrorContent}"/>
        </Trigger>
    </Style.Triggers>
</Style> 

the problem is : My First Column of the Grid is fixed and when i scroll horizontally , the error cell (with red border) overlaps the static columns.

expectation : as soon as the cell starts going behind the fixed column it should hide the border same as other content on the grid.

Any suggestions?

Ujju
  • 43
  • 1
  • 5
  • 2
    I assume the Adorner gets drawn above the column because it's on the AdornerLayer of the Grid. Wrapping the DockPanel in an ` ` should solve it. – Lennart Jul 10 '18 at 08:05
  • @Lennart thanks for the quick suggestion..I tried this option after your suggestion and honestly should resolve the issue but unfortunately it doesn't solve the purpose for me...I was searching different threads on the forum [like this one](https://stackoverflow.com/questions/10294498/error-template-is-displayed-above-other-controls-when-it-should-be-hidden) and all were suggesting the same solution suggested by you. i have wrapped both my TextBlock and DockPanel inside the adorners but no luck. – Ujju Jul 11 '18 at 05:06

0 Answers0