Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This example shows how to create and use a Style for a ToolTip control.
Example
The following example defines a style called Simple
that offsets the placement of a ToolTip and changes its appearance by setting the background, foreground, font size, and font weight.
<Style x:Key="Simple" TargetType="{x:Type ToolTip}">
<Setter Property = "HorizontalOffset" Value="50"/>
<Setter Property = "VerticalOffset" Value="50"/>
<Setter Property = "Background" Value="LightBlue"/>
<Setter Property = "Foreground" Value="Purple"/>
<Setter Property = "FontSize" Value="20"/>
<Setter Property = "FontWeight" Value="Bold"/>
</Style>
The following example shows how to set the Style of a ToolTip that is defined on a TextBlock.
<TextBox HorizontalAlignment="Left">TextBox with ToolTip
<TextBox.ToolTip>
<ToolTip Style="{StaticResource Simple}">
<TextBlock>useful information goes here</TextBlock>
</ToolTip>
</TextBox.ToolTip>
</TextBox>
For the complete sample, see ToolTip Styles Sample.
See Also
Tasks
How to: Use the ContextMenuService