I am using the following template for validation error:
<ControlTemplate>
<Border BorderBrush="Red" BorderThickness="1">
<Grid>
<Polygon Points="8,8 8,0 0,0"
Stroke="Black"
StrokeThickness="1"
Fill="Red"
HorizontalAlignment="Right"
VerticalAlignment="Top"
ToolTip="{Binding ElementName=adorner, Path=AdornedElement.(Validation.Errors)[0].ErrorContent}" />
<AdornedElementPlaceholder x:Name="adorner"/>
</Grid>
</Border>
</ControlTemplate>
ToolTip is working fine, but after leaving the current record the following exception is thrown:
System.Windows.Data Error: 17 : Cannot get 'Item[]' value (type 'ValidationError') from '(Validation.Errors)' (type 'ReadOnlyObservableCollection`1'). BindingExpression:Path=AdornedElement.(0)[0].ErrorContent; DataItem='AdornedElementPlaceholder' (Name='adorner'); target element is 'Polygon' (Name=''); target property is 'ToolTip' (type 'Object') ArgumentOutOfRangeException:'System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
I tried with HasError
property, but failed. Anyone has any idea?