ToolTipService.PlacementTarget Attached Property

Microsoft Silverlight will reach end of support after October 2021. Learn more.

Gets or sets the visual element that the tooltip should be positioned in relation to.

Namespace:  System.Windows.Controls
Assembly:  System.Windows (in System.Windows.dll)

Syntax

'Declaration
See GetPlacementTarget, SetPlacementTarget
See GetPlacementTarget, SetPlacementTarget
<object ToolTipService.PlacementTarget="{Binding ElementName=placementTargetName}"/>

XAML Values

  • placementTargetName
    The Name or x:Name of the UI element that serves as the placement target. This syntax assumes that the working data context contains the named element. For more information, see ElementName.

Property Value

Type: System.Windows.UIElement
The visual element that the tooltip should be displayed in relation to.

Remarks

Dependency property identifier field: PlacementTargetProperty 

Setting the PlacementTarget property on ToolTipService takes precedence over the PlacementTarget value of ToolTip, when the tooltip is activated with the mouse.

The PlacementTarget does not have to be the object on which the tooltip is defined. For example, a TextBlock that describes an Image could specify its tooltip to appear over the Image when the user pauses the mouse pointer on the TextBlock.

If you do not specify a PlacementTarget and the tooltip has a visual parent, the visual parent acts as the PlacementTarget. If the tooltip does not have a visual parent and the value of the PlacementTarget property is nulla null reference (Nothing in Visual Basic), the tooltip control is positioned relative to the upper-left corner of the screen.

This property is an attached property. For information about how to get or set this property in code, see the GetPlacementTarget and SetPlacementTarget methods.

Examples

The following example shows how to set the PlacementTarget property.

Run this sample

<StackPanel Orientation="Horizontal">
    <Ellipse Height="45" Width="50" 
        Fill="Red" 
        HorizontalAlignment="Left"
        ToolTipService.Placement="Right" 
        ToolTipService.PlacementTarget="{Binding ElementName=TB1}"
        ToolTipService.ToolTip="Type the name of the shape in the box." />
    <TextBox Margin="5" x:Name="TB1" Text="ellipse"  Width="200" />
    </StackPanel>
    <StackPanel Orientation="Horizontal">
        <Rectangle Height="45" Width="50" 
        Fill="Blue" 
        HorizontalAlignment="Left"
        ToolTipService.Placement="Right" 
        ToolTipService.PlacementTarget="{Binding ElementName=TB2}"
        ToolTipService.ToolTip="Type the name of the shape in the box." />
        <TextBox Margin="5" x:Name="TB2" Width="200" />
    </StackPanel>
</StackPanel>

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.