Export (0) Print
Expand All

How to: Set the Placement Property for a Popup or Tooltip

.NET Framework 3.0

This example shows how the PlacementMode enumeration values help you position a Popup or a tooltip control. Use the PlacementMode enumeration values to set the System.Windows.Controls.Primitives.Popup.Placement, System.Windows.Controls.ToolTip.Placement, and System.Windows.Controls.ToolTipService.Placement properties.

Example

NoteNote:

This topic discusses only one of the five properties that you use to position a Popup or tooltip control. Before you read this topic, read How to: Position a Popup or How to: Position a ToolTip. Use the information in this topic together with the information in those related topics.

The PlacementMode enumeration works together with other properties to position tooltips and Popup controls. Tooltips, which you create by using the ToolTip control or the ToolTipService, have the same positioning rules as the Popup control. Therefore, although the following examples specifically refer to the Popup control, they also generically apply to tooltips. For more information about all the properties that you use to position a Popup or tooltip, see the topics that are specified in the previous note. For more information about tooltips, see the ToolTip Overview.

The PlacementMode enumeration defines the possible values of the Placement property. Each PlacementMode enumeration defines a method of positioning the Popup window for a point or an element. The following illustration shows how a Popup or a tooltip is positioned. The Placement property in this example has a value of Bottom. This value positions the Popup below the point that is defined by the other properties.

Popup and tooltip placement properties
Popup placement diagram

The following illustrations and definitions show how the PlacementMode enumeration values help you place the Popup window and adjust its position when screen boundaries obscure its content.

The placement of a tooltip follows the same rules as the placement of a Popup window. Tooltip placement properties that are equivalent to the Popup placement properties exist on the ToolTip and ToolTipService classes. For more information, see How to: Position a ToolTip.

PlacementMode = Absolute

A position of the Popup control that is relative to the upper-left corner of the screen and offset by the HorizontalOffset and VerticalOffset properties.

Absolute Popup placement

If a screen edge hides all or part of the Popup, the control realigns with the obscuring edge.

Absolute Popup placement

PlacementMode = AbsolutePoint

A position of the Popup control that is relative to the upper-left corner of the screen and offset by the HorizontalOffset and VerticalOffset properties.

Absolute Popup placement

If a screen edge hides all or part of the Popup, the control opens in the opposite direction by starting at the point that is defined by the offset properties.

PlacementMode = Bottom

A position of the Popup control where the control aligns its upper edge with the lower edge of the PlacementTarget and aligns its left edge with the left edge of the PlacementTarget.

Bottom Popup placement

If the lower edge of the screen hides all or part of the Popup, the control realigns with the upper edge of the PlacementTarget. If the upper edge of the screen hides all or part of this new position, the control realigns with the lower edge of the screen. After these adjustments, if the control is still partially hidden by the upper edge of the screen, the control realigns with the upper edge of the screen.

Bottom Popup placement

If a vertical screen edge hides all or part of the Popup, the control realigns with the obscuring screen edge.

Bottom Popup placement

PlacementMode = Center

A position of the Popup control where the control centers itself over the PlacementTarget.

Center Popup placement

If a screen edge hides all or part of the Popup, the control realigns with the obscuring screen edge.

Center Popup placement

PlacementMode = Left

A Popup control that aligns its right edge with the left edge of the PlacementTarget and its upper edge with the upper edge of the PlacementTarget.

Left Popup placement

If a horizontal screen edge hides all or part of the Popup, the control realigns with the obscuring screen edge.

Left Popup placement

If a vertical screen edge hides all or part of the Popup, the control realigns on the opposite side of the PlacementTarget.

Left Popup placement

PlacementMode = Mouse

A position of the Popup control where it aligns its upper edge with the lower edge of the bounding box of the mouse, and it aligns its left edge with the left edge of the mouse bounding box.

Mouse Popup placement

If a horizontal screen edge hides all or part of the Popup, the control displays on the opposite side of the mouse bounding box.

Mouse Popup placement diagram

If a vertical screen edge hides all or part of the Popup, the control realigns with the obscuring screen edge.

Mouse Popup placement

PlacementMode = MousePoint

A position of the Popup control that aligns its upper edge with the lower edge of the mouse bounding box and its left edge with the left edge of the mouse bounding box.

Mouse Popup placement

If a screen edge hides all or part of the Popup, the control realigns on the opposite side of the mouse bounding box.

Mouse Popup placement diagram

MousePoint Popup placement

PlacementMode = Relative

A position of the Popup control that is relative to the upper-left corner of the PlacementTarget and at an offset that is defined by the HorizontalOffset and VerticalOffset property values.

Relative Popup placement

If a screen edge hides all or part of the Popup, the control realigns with the obscuring screen edge.

Relative Popup placement

Relative Popup placement diagram

Placement Mode = RelativePoint

A position of the Popup control that is relative to the upper-left corner of the PlacementTarget and at an offset that is defined by the HorizontalOffset and VerticalOffset property values.

Relative Popup placement

If a screen edge hides all or part of the Popup, the control opens in the opposite direction by starting at the point that is defined by the offset properties.

RelativePoint Popup placement RelativePoint Popup placement

PlacementMode = Right

A position of the Popup control that aligns its left edge with the right edge of the PlacementTarget and aligns its upper edge with the upper edge of the PlacementTarget.

Right Popup placement

If a vertical screen edge hides all or part of the Popup, the control displays on the opposite side of the PlacementTarget.

Right Popup placement

If the upper or lower screen edge hides all or part of the Popup, the control realigns with the obscuring screen edge.

Placement Mode = Top

A position of the Popup control that aligns its lower edge with the upper edge of the PlacementTarget and aligns its left edge with the left edge of the PlacementTarget.

If the upper edge of the screen hides all or part of the Popup, the control displays below the PlacementTarget. If the lower edge of the screen hides the Popup in the new position, the control realigns with the lower edge of the screen. If the control is still obscured by the upper screen edge in the third position, the control realigns with the upper screen edge.

Top Popup placement

If a vertical screen edge hides all or part of the Popup, the control realigns with the obscuring screen edge.

Top Popup placement

See Also

Community Additions

ADD
Show:
© 2014 Microsoft