Popup.HorizontalOffset Property

Gets or sets the offset from the left of the area that is specified for the Popup control content by a combination of the Placement, PlacementTarget, and PlacementRectangle properties.

Namespace: System.Windows.Controls.Primitives
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public double HorizontalOffset { get; set; }
/** @property */
public double get_HorizontalOffset ()

/** @property */
public void set_HorizontalOffset (double value)

public function get HorizontalOffset () : double

public function set HorizontalOffset (value : double)

<object HorizontalOffset="double"/>
- or -
<object HorizontalOffset="qualifiedDouble"/>
 double   Double  A string representation of a Double value. This is interpreted as a device-independent unit (1/96th inch) measurement. Strings do not have to explicitly include decimal points. For example, a value of 1 is acceptable. The same Double range restrictions apply as those that are mentioned in the Property Value section of this topic.  qualifiedDouble  A double value as described earlier in this table, followed by one of the following unit declaration strings: px, in, cm, or pt.  px (default) is device-independent units (1/96th inch per unit)  in is inches; 1in=96px  cm is centimeters; 1cm=(96/2.54) px  pt is points; 1pt=(96/72) px 

Property Value

An offset from the left of the area that is specified for the Popup control by a combination of the Placement, PlacementTarget, and PlacementRectangle properties. The default value is 0.0.

Identifier field


Metadata properties set to true


The HorizontalOffset property and the VerticalOffset property are designed to provide fine-tuning for the placement of a Popup control. The primary placement properties are the Placement, PlacementTarget, and PlacementRectangle properties.

This set of examples shows how to use the placement properties to specify the position of a Popup control.

You can determine the position of a Popup control by using the following properties:

  • PlacementTarget

  • PlacementRectangle

  • VerticalOffset

  • HorizontalOffset

  • Placement

The first four properties define a two-dimensional coordinate on the screen. The fifth property, Placement, positions the Popup and also defines its behavior if its content overlaps the screen boundaries.

Use a PlacementMode enumeration value to set the Placement property. For more information about the enumeration values for PlacementMode, see How to: Use the PlacementMode Enumeration to set Placement.

The following illustrations show how the placement properties work together to position a Popup control.

Popup placement by using the Placement property

Popup placement

Popup placement by using the Placement and PlacementRectangle properties

Popup placement rectangle

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

Popup placement diagram

The following example shows how to set these Popup properties. For the complete sample, see Popup Position Sample.

Popup myPopup = new Popup();
myPopup.PlacementTarget = myEllipse;
myPopup.PlacementRectangle = new Rect(0, 0, 30, 50);
myPopup.VerticalOffset = 20;
myPopup.HorizontalOffset = 20;
myPopup.Placement = PlacementMode.Bottom;
myPopup.PopupAnimation = PopupAnimation.Fade;
myPopup.AllowsTransparency = true;
TextBlock popupText = new TextBlock();
popupText.Background = Brushes.Beige;
popupText.FontSize = 12;
popupText.Width = 75;
popupText.TextWrapping = TextWrapping.Wrap;
myPopup.Child = popupText;

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.

.NET Framework

Supported in: 3.0

Community Additions