ContextMenu.VerticalOffset 属性

定义

获取或设置目标原点与弹出项对齐点之间的垂直距离。Get or sets the vertical distance between the target origin and the popup alignment point.

public:
 property double VerticalOffset { double get(); void set(double value); };
[System.ComponentModel.Bindable(true)]
[System.ComponentModel.TypeConverter(typeof(System.Windows.LengthConverter))]
public double VerticalOffset { get; set; }
member this.VerticalOffset : double with get, set
Public Property VerticalOffset As Double

属性值

目标原点与弹出项对齐点之间的垂直距离。The vertical distance between the target origin and the popup alignment point. 有关目标原点和 popup 对齐点的信息, 请参阅Popup 放置行为For information about the target origin and popup alignment point, see Popup Placement Behavior. 默认值为 0。The default is 0.

属性

示例

下面的示例演示如何使用VerticalOffset属性ContextMenu使在指定位置 (相对于其按钮父级) 打开。The following example shows how to use the VerticalOffset property to cause a ContextMenu to open at a specified location in relation to its button parent.

<ContextMenu HorizontalOffset="50" VerticalOffset="50" HasDropShadow="false">

注解

ContextMenu Placement PlacementRectangle通过设置、、HorizontalOffset、和VerticalOffsetProperty属性, 可以定位。 PlacementTargetYou can position a ContextMenu by setting the PlacementTarget, PlacementRectangle, Placement, HorizontalOffset, and VerticalOffsetProperty properties. 这些属性的行为与对Popup的行为相同。These properties behave the same as they do for a Popup. 有关详细信息,请参阅 Popup 放置行为For more information, see Popup Placement Behavior.

依赖项属性信息Dependency Property Information

标识符字段Identifier field VerticalOffsetProperty
元数据属性设置为trueMetadata properties set to true NoneNone

XAML 属性用法XAML Attribute Usage

<object VerticalOffset="double"/>  
- or -  
<object VerticalOffset ="qualifiedDouble"/>  

XAML 值XAML Values

doubledouble
Double

Double值的字符串表示形式。String representation of a Double value. 这会被解释为与设备无关的单位(1/96 英寸)device-independent unit (1/96th inch)度量值。This is interpreted as a 与设备无关的单位(1/96 英寸)device-independent unit (1/96th inch) measurement. 字符串不需要显式包含小数点。Strings need not explicitly include decimal points. 例如, 的1值是可接受的。For instance, a value of 1 is acceptable. 与属性Double值部分中提到的范围限制相同。The same Double range restrictions as mentioned in the Property Value section apply.

qualifiedDoublequalifiedDouble
如上所述的双精度值, 后跟以下单元声明字符串之一px:、 incmptA double value as described above, followed by one of the following unit declaration strings: px, in, cm, pt.

px(默认值) 是与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)px (default) is 与设备无关的单位(每个单位 1/96 英寸)device-independent units (1/96th inch per unit)

in为英寸;1in = = 96pxin is inches; 1in==96px

cm为厘米;1cm = = (96/2.54) pxcm is centimeters; 1cm==(96/2.54) px

pt为点;1pt = = (96/72) pxpt is points; 1pt==(96/72) px

备注

在许多情况下, double 可以设置为 auto, 但ContextMenu如果偏移量设置为 auto, 则不会显示。In many cases a double may be set to Auto, but a ContextMenu does not appear if the offsets are set to Auto.

适用于

另请参阅