Popup.PlacementRectangle 属性


获取或设置当打开 Popup 控件时该控件相对于其放置的矩形。Gets or sets the rectangle relative to which the Popup control is positioned when it opens.

 property System::Windows::Rect PlacementRectangle { System::Windows::Rect get(); void set(System::Windows::Rect value); };
public System.Windows.Rect PlacementRectangle { get; set; }
member this.PlacementRectangle : System.Windows.Rect with get, set
Public Property PlacementRectangle As Rect


用于放置 Popup 控件的矩形。The rectangle that is used to position the Popup control. 默认值为 nullThe default is null.



下面的示例设置PlacementRectangle的属性。 PopupThe following example sets the PlacementRectangle property of a Popup. XY 、、和Height属性分别为50、50、50和100。 Width PlacementRectangleThe X, Y, Width, and Height properties of the PlacementRectangle are 50, 50, 50, and 100, respectively. 是相对于PlacementRectangle属性边界的。 PopupThe Popup is relative to the bounds of the PlacementRectangle property. 请注意, PlacementRectangle此属性不会在应用程序中创建可见的元素; 此示例Rectangle将创建一个具有相同边界来PlacementRectangle表示的。Note that the PlacementRectangle property does not create a visible element in the application; the example creates a Rectangle with the same bounds to represent the PlacementRectangle.

<Canvas Width="200" Height="200" Background="Red">
  <Rectangle Canvas.Top="50" Canvas.Left="50" 
             Width="50" Height="100"
             Stroke="White" StrokeThickness="3"/>
  <Popup IsOpen="True" PlacementRectangle="50,50,50,100">
    <TextBlock FontSize="14" Background="Yellow"
               Width="140" TextWrapping="Wrap">
      This is a popup with a PlacementRectangle.


可以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 PlacementRectangleProperty
元数据属性设置为trueMetadata properties set to true NoneNone