Need Help Applying the ErrorContent to an Image's ToolTip
I'm trying to style the tooltip for an image that I'm using for
validation. Everything works fine except the ErrorContent does not render
in the tooltip.
<Style x:Key="ErrorToolTip" TargetType="{x:Type ToolTip}">
<Setter Property="Background" Value="#FFDC000C"/>
<Setter Property="Foreground" Value="White"/>
</Style>
<Style x:Key="Validation" TargetType="Control">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,2,40,2" />
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<Border>
<DockPanel>
<Image
Source="/Foundation.Finance.Receipts.Windows;component/Resources/errorimage.png"
Width="17" Height="17"
Margin="5,0,0,0"
DockPanel.Dock="Right">
<ToolTipService.ToolTip>
<ToolTip Style="{StaticResource
ErrorToolTip}">
<TextBlock Text="{Binding
ElementName=customAdorner,
Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"/>
</ToolTip>
</ToolTipService.ToolTip>
</Image>
<AdornedElementPlaceholder
Name="customAdorner"
VerticalAlignment="Center" >
<Border BorderBrush="#FFDC000C"
BorderThickness="1" />
</AdornedElementPlaceholder>
</DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="TextBox" BasedOn="{StaticResource Validation}"/>
<Style TargetType="telerik:RadComboBox" BasedOn="{StaticResource
Validation}"/>
The following works, but does not style the image's tooltip.
<Style x:Key="Validation" TargetType="Control">
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="Margin" Value="0,2,40,2" />
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<Border>
<DockPanel>
<Image
Source="/Foundation.Finance.Receipts.Windows;component/Resources/errorimage.png"
Width="17" Height="17"
Margin="5,0,0,0"
ToolTip="{Binding
ElementName=customAdorner,
Path=AdornedElement.(Validation.Errors)[0].ErrorContent}"
DockPanel.Dock="Right">
</Image>
<AdornedElementPlaceholder
Name="customAdorner"
VerticalAlignment="Center" >
<Border BorderBrush="#FFDC000C"
BorderThickness="1" />
</AdornedElementPlaceholder>
</DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<Style TargetType="TextBox" BasedOn="{StaticResource Validation}"/>
<Style TargetType="telerik:RadComboBox" BasedOn="{StaticResource
Validation}"/>
No comments:
Post a Comment