I have created a style for a tooltip. This is the style:
<Style TargetType="ToolTip" x:Key="ToolTipDefaultStyle">
<Setter Property="ToolTipService.ShowOnDisabled" Value="true"/>
<Setter Property="ToolTipService.InitialShowDelay" Value="{StaticResource TooltipInitialShowDelay}"/>
<Setter Property="ToolTipService.ShowDuration" Value="{StaticResource TooltipDisplayTime}"/>
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=ToolTip}}" TextWrapping='Wrap'
Margin="10"/>
</StackPanel>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
And this is I use it in a control:
<StackPanel ToolTip="{Binding MyViewModelProperty}">
..........
<StackPanel.Resources>
<Style TargetType="ToolTip" BasedOn="{StaticResource ToolTipDefaultStyle}"/>
</StackPanel.Resources>
</StackPanel>
The problem is that tooltip, at the start, it shows this text: "System.Windows.Controls.ToolTip". After that, it shows the text I want to show.
How could avoid to show this first text?
What I want to have is a style for all the controls of the application.
Thanks.
The ToolTip
control is a ContentControl
. The ContentTemplate
's DataContext
will be the Content
property.
So you just need to change your TextBlock
binding to:
<TextBlock
Margin="10"
Text="{Binding}"
TextWrapping="Wrap" />