ToolTipService.PlacementTarget Attached Property

Gets or sets the object relative to which the tooltip is positioned.

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

See ToolTipService.GetPlacementTarget, ToolTipService.SetPlacementTarget
See ToolTipService.GetPlacementTarget, ToolTipService.SetPlacementTarget
See ToolTipService.GetPlacementTarget, ToolTipService.SetPlacementTarget
<object ToolTipService.PlacementTarget="UIElement" .../>

Property Value

The UIElement that is the logical parent of the ToolTip control. The default value is a null reference (Nothing in Visual Basic).

Identifier field


Metadata properties set to true


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 a 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.

This example shows how to specify the position of a tooltip on the screen.

You can position a tooltip by using a set of five properties that are defined in both the ToolTip and ToolTipService classes. The following table shows these two sets of five properties and provides links to their reference documentation according to class.

Corresponding tooltip properties according to class

If you define the contents of a tooltip by using a ToolTip object, you can use the properties of either class; however, the ToolTipService properties take precedence. Use the ToolTipService properties for tooltips that are not defined as ToolTip objects.

The following illustrations show how to position a tooltip by using these properties. Although, the Extensible Application Markup Language (XAML) examples in these illustrations show how to set the properties that are defined by the ToolTip class, the corresponding properties of the ToolTipService class follow the same layout rules. For more information about the possible values for the Placement property, see How to: Use the PlacementMode Enumeration to set Placement.

ToolTip placement by using the Placement property

ToolTip placement

ToolTip placement by using the Placement and PlacementRectangle properties

ToolTip placement by using the Placement, PlacementRectangle, and Offset properties

ToolTip placement diagram

The following example shows how to use the ToolTip properties to specify the position of a tooltip whose content is a ToolTip object.

<Ellipse Height="25" Width="50" 
    <ToolTip Placement="Right" 
          <Ellipse Height="10" Width="20" Fill="Blue"/>
        <TextBlock>Uses the ToolTip Class</TextBlock>

//Create an ellipse with a tooltip that is a 
//ToolTip control 
Ellipse ellipse1 = new Ellipse();
ellipse1.Height = 25;
ellipse1.Width = 50;
ellipse1.Fill = Brushes.Gray;
ellipse1.HorizontalAlignment = HorizontalAlignment.Left;

//set tooltip timing 

ToolTipService.SetInitialShowDelay(ellipse1, 1000);

ToolTipService.SetBetweenShowDelay(ellipse1, 2000);

ToolTipService.SetShowDuration(ellipse1, 7000);

//set tooltip placement
ToolTip tooltip = new ToolTip();
tooltip.Placement = PlacementMode.Right;
tooltip.PlacementRectangle = new Rect(50, 0, 0, 0);
tooltip.HorizontalOffset = 10;
tooltip.VerticalOffset = 20;

//set drop shadow effect
tooltip.HasDropShadow = false;

//Create BulletDecorator as tooltip content
BulletDecorator bdec = new BulletDecorator();
Ellipse littleEllipse = new Ellipse();
littleEllipse.Height = 10;
littleEllipse.Width = 20;
littleEllipse.Fill = Brushes.Blue;
bdec.Bullet = littleEllipse;
TextBlock tipText = new TextBlock();
tipText.Text = "Uses the ToolTip class";
bdec.Child = tipText;
tooltip.Content = bdec;

//set event handlers for the Opened and Closed events
tooltip.Opened +=
  new RoutedEventHandler(whenToolTipOpens);
tooltip.Closed +=
  new RoutedEventHandler(whenToolTipCloses);

//set tooltip on ellipse
ellipse1.ToolTip = tooltip;

The following example shows how to use the ToolTipService properties to specify the position of a tooltip whose content is not a ToolTip object.

    <Ellipse Height="25" Width="50" 
        <Ellipse Height="10" Width="20" Fill="Blue"/>
      <TextBlock>Uses the ToolTipService class</TextBlock>

//Create and Ellipse with the BulletDecorator as 
//the tooltip 
Ellipse ellipse2 = new Ellipse();
ellipse2.Name = "ellipse2";
ellipse2.Height = 25;
ellipse2.Width = 50;
ellipse2.Fill = Brushes.Gray;
ellipse2.HorizontalAlignment = HorizontalAlignment.Left;

//set tooltip timing
ToolTipService.SetInitialShowDelay(ellipse2, 1000);
ToolTipService.SetBetweenShowDelay(ellipse2, 2000);
ToolTipService.SetShowDuration(ellipse2, 7000);

//set tooltip placement

ToolTipService.SetPlacement(ellipse2, PlacementMode.Right);

    new Rect(50, 0, 0, 0));

ToolTipService.SetHorizontalOffset(ellipse2, 10.0);

ToolTipService.SetVerticalOffset(ellipse2, 20.0);

ToolTipService.SetHasDropShadow(ellipse2, false);

ToolTipService.SetIsEnabled(ellipse2, true);

ToolTipService.SetShowOnDisabled(ellipse2, true);

    new RoutedEventHandler(whenToolTipOpens));
    new RoutedEventHandler(whenToolTipCloses));
//define tooltip content
BulletDecorator bdec2 = new BulletDecorator();
Ellipse littleEllipse2 = new Ellipse();
littleEllipse2.Height = 10;
littleEllipse2.Width = 20;
littleEllipse2.Fill = Brushes.Blue;
bdec2.Bullet = littleEllipse2;
TextBlock tipText2 = new TextBlock();
tipText2.Text = "Uses the ToolTipService class";
bdec2.Child = tipText2;
ToolTipService.SetToolTip(ellipse2, bdec2);

For the complete sample, see ToolTipService Sample.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.