StackPanel.Orientation プロパティ

定義

子要素がスタックされる次元を示す値を取得または設定します。Gets or sets a value that indicates the dimension by which child elements are stacked.

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

プロパティ値

子コンテンツの OrientationThe Orientation of child content.

次の例は、 Orientationプロパティを使用して、 StackPanel内の要素を積み重ねる方法を指定する方法を示しています (一方の上に1つまたは左右に並べられています)。The following example shows how to use the Orientation property to specify how elements within a StackPanel are stacked (one on top of the other or side by side).

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

次のスクリーンショットは、この例がどのようにレンダリングされるかを示しています。The screenshot below shows how this example renders.

StackPanel の向きStackPanel orientation

注釈

依存プロパティ情報Dependency Property Information

識別子フィールドIdentifier field OrientationProperty
メタデータプロパティがに設定されるtrueMetadata properties set to true AffectsMeasure

適用対象