StackPanel.Orientation プロパティ

定義

子要素がスタックされる次元を示す値を取得または設定します。

public System.Windows.Controls.Orientation Orientation { get; set; }

プロパティ値

子コンテンツの Orientation

次の例では、 プロパティを Orientation 使用して、 内 StackPanel の要素を積み重ねる方法を指定する方法を示します (一方はもう一方の要素の上または横に並んでいます)。

<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">

  <!-- This StackPanel stacks two other StackPanels on top of each other. The
       first StackPanel stacks its items horizontally while the second stacks them
       vertically. -->
  <StackPanel>

    <!-- The items under this StackPanel are stacked horizontally. -->
    <StackPanel Orientation="Horizontal">
      <Border Background="SkyBlue">
        <TextBlock>Stacked Item #1</TextBlock>
      </Border>
      <Border Background="CadetBlue">
        <TextBlock>Stacked Item #2</TextBlock>
      </Border>
      <Border Background="LightGoldenRodYellow">
        <TextBlock>Stacked Item #3</TextBlock>
      </Border>
    </StackPanel>

    <!-- The items under this StackPanel are stacked Vertically. Note that Orientation 
         has a default value of "Vertical" but in this example the property is explicitely
         set for clarity. -->
    <StackPanel Orientation="Vertical">
      <Border Background="SkyBlue">
        <TextBlock>Stacked Item #1</TextBlock>
      </Border>
      <Border Background="CadetBlue">
        <TextBlock>Stacked Item #2</TextBlock>
      </Border>
      <Border Background="LightGoldenRodYellow">
        <TextBlock >Stacked Item #3</TextBlock>
      </Border>
    </StackPanel>
  </StackPanel>
  
</Page>

次のスクリーンショットは、この例がどのようにレンダリングされるかを示しています。

StackPanel の向き

注釈

依存プロパティ情報

識別子フィールド OrientationProperty
に設定されたメタデータ プロパティ true AffectsMeasure

適用対象

製品 バージョン
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9