My problem is, that I don't get the ToolTip Text thrown by the SetterException of my binding object.
I have a ControlTemplate like this:
<ControlTemplate x:Key="textBoxErrorTemplate" >
<Grid Margin="-15,5,0,0" ToolTip="{Binding RelativeSource={RelativeSource TemplatedParent},Path=(Validation.Errors)[0].ErrorContent}">
<Ellipse StrokeThickness="0" Fill="Red" Width="{TemplateBinding FontSize}" Height="{TemplateBinding FontSize}" />
<TextBlock Text="!" FontSize="{TemplateBinding FontSize}" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center" />
</Grid>
</ControlTemplate>
I also tried
ToolTip="{Binding RelativeSource={RelativeSource Self},Path=(Validation.Errors)[0].ErrorContent}"
ToolTip="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TextBox}},Path=(Validation.Errors)[0].ErrorContent}"
My TextBox looks like this:
<TextBox Grid.Row="1" Grid.Column="1" Name="tbMin" SourceUpdated="tb_SourceUpdated" Validation.ErrorTemplate="{StaticResource textBoxErrorTemplate}"/>
I'm binding the data source in code like this:
Binding bindMinString = new Binding("MinString");
bindMinString.Source = curStep;
bindMinString.NotifyOnSourceUpdated = true;
bindMinString.ValidatesOnExceptions = true;
bindMinString.UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged;
tbMin.SetBinding(TextBox.TextProperty, bindMinString);
The template seems to work (I see the ellipse with the "!"), but I don't see my exception message.
Binding
in yourErrorTemplate
, try using{RelativeSource Self}
instead of{RelativeSource TemplatedParent}
.<AdornedElementPlaceholder/>
.