Popup.HorizontalOffset 属性


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

 property double HorizontalOffset { double get(); void set(double value); };
public double HorizontalOffset { get; set; }
member this.HorizontalOffset : double with get, set
Public Property HorizontalOffset As Double


目标原点与弹出项对齐点之间的水平距离。The horizontal 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.



下面的示例创建一个Popup , 并HorizontalOffset将和VerticalOffset属性设置为20。The following example creates a Popup and sets the HorizontalOffset and VerticalOffset properties to 20. 属性设置为Bottom (默认值), 因此目标原点是目标区域的左下角, popup 对齐点是的Popup左上角。 PlacementThe Placement property is set to Bottom (which is the default), so the target origin is the bottom left corner of the target area and the popup alignment point is the top left corner of the Popup.

<Canvas Width="200" Height="200" Background="Yellow" Margin="20">
  <Popup IsOpen="True" Placement="Bottom"
         HorizontalOffset="20" VerticalOffset="20">
    <TextBlock FontSize="14" Background="#42F3FD">
      This is a popup.


可以PlacementTarget通过设置、 Placement PlacementRectangle、 、HorizontalOffsetVerticalOffset属性来定位 popup。You can position a popup by setting the PlacementTarget, PlacementRectangle, Placement, HorizontalOffset, and VerticalOffset properties. 有关详细信息,请参阅 Popup 放置行为For more information, see Popup Placement Behavior.

依赖项属性信息Dependency Property Information

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

XAML 属性用法XAML Attribute Usage

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



Double值的字符串表示形式。A 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 do not have to explicitly include decimal points. 例如, 的1值是可接受的。For example, a value of 1 is acceptable.

相同Double范围限制适用于本主题的属性值部分中提到的限制。The same Double range restrictions apply as those that are mentioned in the Property Value section of this topic.

double表前面所述的值, 后跟以下单元声明字符串之一: pxincmptA double value as described earlier in this table, followed by one of the following unit declaration strings: px, in, cm, or 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