Popup.Placement 属性

定义

获取或设置 Popup 控件打开时的控件方向,并指定 Popup 控件在与屏幕边界重叠时的控件行为。Gets or sets the orientation of the Popup control when the control opens, and specifies the behavior of the Popup control when it overlaps screen boundaries.

public:
 property System::Windows::Controls::Primitives::PlacementMode Placement { System::Windows::Controls::Primitives::PlacementMode get(); void set(System::Windows::Controls::Primitives::PlacementMode value); };
[System.ComponentModel.Bindable(true)]
public System.Windows.Controls.Primitives.PlacementMode Placement { get; set; }
member this.Placement : System.Windows.Controls.Primitives.PlacementMode with get, set
Public Property Placement As PlacementMode

属性值

一个 PlacementMode 枚举值,该值确定 Popup 控件打开时的控件方向,并指定该控件与屏幕边界交互的方式。A PlacementMode enumeration value that determines the orientation of the Popup control when the control opens, and that specifies how the control interacts with screen boundaries. 默认值为 BottomThe default is Bottom.

属性

示例

下面的示例创建了Popup四个相对于图像的控件。The following example creates four Popup controls that are relative to an image. 对于Popup "位置" 属性, 每个值都有不同的值。Each Popup has a different value for the placement property.

<Canvas Width="200" Height="150">
  <Image Name="image1"
         Canvas.Left="75" 
         Source="Water_lilies.jpg" Height="200" Width="200"/>
  <Popup IsOpen="True" PlacementTarget="{Binding ElementName=image1}"
         Placement="Bottom">
    <TextBlock FontSize="14" Background="LightGreen">Placement=Bottom</TextBlock>

  </Popup>
  <Popup IsOpen="True" PlacementTarget="{Binding ElementName=image1}"
         Placement="Top">
    <TextBlock FontSize="14" Background="LightGreen">Placement=Top</TextBlock>

  </Popup>
  <Popup IsOpen="True" PlacementTarget="{Binding ElementName=image1}"
         Placement="Left">
    <TextBlock FontSize="14" Background="LightGreen">Placement=Left</TextBlock>

  </Popup>
  <Popup IsOpen="True" PlacementTarget="{Binding ElementName=image1}"
         Placement="Right">
    <TextBlock FontSize="14" Background="LightGreen">Placement=Right</TextBlock>

  </Popup>
</Canvas>

注解

可以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.

Left Right Popup Popup如果属性为true, 则将Placement设置为或反转的位置; Left如果设置为, 则设置为将其左边缘与Placement MenuDropAlignmentPlacementTarget PlacementTarget和的右Placement边缘, 其右边缘与的左边缘对齐。 Right PopupIf the MenuDropAlignment property is true, setting Placement to Left or Right reverses the position of the Popup; a Popup with Placement set to Left aligns its left edge with the right edge of PlacementTarget and a Popup with Placement set to Right aligns its right edge with the left edge of PlacementTarget.

依赖项属性信息Dependency Property Information

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

适用于

另请参阅