Popup.PlacementTarget Property

Definition

Gets or sets the element relative to which the Popup is positioned when it opens.

C#
[System.ComponentModel.Bindable(true)]
public System.Windows.UIElement PlacementTarget { get; set; }

Property Value

The UIElement that is the logical parent of the Popup control. The default is null.

Attributes

Examples

The following example creates a Popup that is the child of a Canvas, and sets PlacementTarget to ellipse1, so the popup is relative to the Ellipse.

XAML
<Canvas Margin="5" Background="Red" Width="200" Height="150" >

  <Ellipse Name="ellipse1"
           Canvas.Top="60" Canvas.Left="50"
           Height="85" Width="60" 
           Fill="Black"/>

  <Popup IsOpen="True" PlacementTarget="{Binding ElementName=ellipse1}">
    <TextBlock Background="LightBlue" FontSize="18">This is a Popup</TextBlock>
  </Popup>
</Canvas>

Remarks

You can position a popup by setting the PlacementTarget, PlacementRectangle, Placement, HorizontalOffset, and VerticalOffset properties. For more information, see Popup Placement Behavior.

Dependency Property Information

Item Value
Identifier field PlacementTargetProperty
Metadata properties set to true None

Applies to

Product Versions
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

See also