Popup.Placement 屬性

定義

取得或設定 Popup 控制項開啟時的方向,以及指定當 Popup 控制項與畫面邊界重疊時的行為。

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; }
[<System.ComponentModel.Bindable(true)>]
member this.Placement : System.Windows.Controls.Primitives.PlacementMode with get, set
Public Property Placement As PlacementMode

屬性值

PlacementMode

PlacementMode 列舉值,決定 Popup 控制項開啟時的方向,以及指定控制項與畫面互動時的行為。 預設為 Bottom

屬性

範例

下列範例會建立四 Popup 個相對於影像的控制項。 每個位置 Popup 屬性都有不同的值。

<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>

備註

您可以藉由設定 、 PlacementRectanglePlacementHorizontalOffsetVerticalOffset 屬性來 PlacementTarget 定位快顯視窗。 如需詳細資訊,請參閱快顯放置行為

MenuDropAlignment如果 屬性為 true ,則設定 PlacementLeftRight 反轉 的位置 Popup ; Popup ,設定 Placement 為 ,其 Left 左邊緣與 的右邊緣對齊,而 Popup Placement 設定為 ,使其 Right 右邊緣與 的左 PlacementTarget 邊緣 PlacementTarget 對齊。

相依性屬性資訊

識別碼欄位 PlacementProperty
中繼資料屬性設定為 true

適用於

另請參閱