HorizontalOffset Attached Property

ContextMenuService.HorizontalOffset Attached Property


Gets or sets a value that indicates where along the x-direction to place the ContextMenu with respect to the parent control.

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

See GetHorizontalOffset, SetHorizontalOffset

Property Value

Type: System.Double

Double that specifies the horizontal placement of the ContextMenu.

You can position a ContextMenu by setting the PlacementTarget, PlacementRectangle, Placement, HorizontalOffset, and VerticalOffsetProperty properties. These properties behave the same as they do for a Popup. For more information, see Popup Placement Behavior.

Identifier field


Metadata properties set to true


<object HorizontalOffset="double"/>
- or –
<object HorizontalOffset="qualifiedDouble"/>



A string representation of a Double value. This is interpreted as a device-independent unit (1/96th inch) measurement. Strings need not explicitly include decimal points. For instance a value of 1 is acceptable.


A double value as described above, followed by one of the following unit declaration strings: px, in, cm, 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

The following example assigns the same ContextMenu to two buttons and sets the HasDropShadow, Placement, PlacementRectangle, HorizontalOffset, and VerticalOffset properties to set the ContextMenu to different positions for each button.

Return to top
© 2015 Microsoft