ItemsPanelTemplate クラス

定義

ItemsPresenter の項目のレイアウト用に ItemsControl が作成するパネルを指定します。

public ref class ItemsPanelTemplate : System::Windows::FrameworkTemplate
public class ItemsPanelTemplate : System.Windows.FrameworkTemplate
type ItemsPanelTemplate = class
    inherit FrameworkTemplate
Public Class ItemsPanelTemplate
Inherits FrameworkTemplate
継承

水平方向を作成するには、水平方向 ListBoxを指定 StackPanel し、プロパティとして設定するテンプレートを ItemsPanel 作成できます。 次の例は、水平ListBoxListBoxStyle作成する例を示しています。

<Style TargetType="ListBox">
  <Setter Property="ItemsPanel">
    <Setter.Value>
      <ItemsPanelTemplate>
        <StackPanel Orientation="Horizontal"
                    VerticalAlignment="Center"
                    HorizontalAlignment="Center"/>
      </ItemsPanelTemplate>
    </Setter.Value>
  </Setter>
</Style>

次の例では、角が丸い水平ListBoxを作成するために a ControlTemplate を使用します。 この例では、前の例のようにプロパティをItemsPanel設定する代わりに、水平StackPanelは .ControlTemplate プロパティはIsItemsHost、生成された項目がパネルにStackPanel表示されることを示す上に設定trueされていることに注意してください。 この方法で指定すると、コントロールの ItemsPanel ユーザー ControlTemplateに置き換えることはできません。 したがって、これは、テンプレートを使用せずにパネルを置き換えたくないことがわかっている場合にのみ行います。

<Style TargetType="ListBox">
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="ListBox">
        <Border CornerRadius="5" Background="{TemplateBinding ListBox.Background}">
          <ScrollViewer HorizontalScrollBarVisibility="Auto">
            <StackPanel Orientation="Horizontal"
                       VerticalAlignment="Center"
                       HorizontalAlignment="Center"
                       IsItemsHost="True"/>
          </ScrollViewer>
        </Border>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

または、次の操作を実行して、同じ結果を得ることもできます。 この場合、 ItemsPresenter 項目のレイアウト用のパネルが作成されます ItemsPanelTemplate

<Style TargetType="{x:Type ListBox}">
  <Setter Property="ItemsPanel">
    <Setter.Value>
      <ItemsPanelTemplate>
        <StackPanel Orientation="Horizontal"
                     VerticalAlignment="Center"
                     HorizontalAlignment="Center"/>
      </ItemsPanelTemplate>
    </Setter.Value>
  </Setter>
  <Setter Property="Template">
    <Setter.Value>
      <ControlTemplate TargetType="{x:Type ListBox}">
        <Border CornerRadius="5"
                Background="{TemplateBinding ListBox.Background}">
          <ScrollViewer HorizontalScrollBarVisibility="Auto">
            <ItemsPresenter/>
          </ScrollViewer>
        </Border>
      </ControlTemplate>
    </Setter.Value>
  </Setter>
</Style>

さまざまなスタイル設定プロパティとテンプレート プロパティを使用する方法の例については、「データ テンプレートItemsControl概要」を参照してください。

注釈

項目 ItemsPanelTemplate のレイアウトに使用するパネルを指定します。 GroupStyle には、 PanelItemsPanelTemplateのプロパティがあります。 ItemsControl 型には、 ItemsPanelItemsPanelTemplateのプロパティがあります。

ItemsControl 型には既定値 ItemsPanelTemplateがあります。 クラスのItemsControl既定値ItemsPanelItemsPanelTemplateStackPanel、 の場合、 ListBox既定値 VirtualizingStackPanelでは . の場合 MenuItem、既定で使用 WrapPanelされます。 の場合 StatusBar、既定で使用 DockPanelされます。

コンストラクター

ItemsPanelTemplate()

ItemsPanelTemplate クラスのインスタンスを初期化します。

ItemsPanelTemplate(FrameworkElementFactory)

指定したテンプレートを使用して、ItemsPanelTemplate クラスのインスタンスを初期化します。

プロパティ

Dispatcher

この Dispatcher が関連付けられている DispatcherObject を取得します。

(継承元 DispatcherObject)
HasContent

最適化されたコンテンツがこのテンプレートに含まれているかどうかを示す値を取得します。

(継承元 FrameworkTemplate)
IsSealed

このオブジェクトが不変の状態で変更不可能であるかどうかを示す値を取得します。

(継承元 FrameworkTemplate)
Resources

このテンプレートのスコープ内で使用できるリソースのコレクションを取得または設定します。

(継承元 FrameworkTemplate)
Template

ライターがテンプレートを定義または適用するときに、テンプレートの XAML ノードを記録または再生するオブジェクトへの参照を取得または設定します。

(継承元 FrameworkTemplate)
VisualTree

テンプレートのルート ノードを取得または設定します。

(継承元 FrameworkTemplate)

メソッド

CheckAccess()

呼び出し元のスレッドがこの DispatcherObject にアクセスできるかどうかを確認します。

(継承元 DispatcherObject)
Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
FindName(String, FrameworkElement)

このテンプレート内で定義された、指定した名前に関連付けられている要素を検索します。

(継承元 FrameworkTemplate)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
LoadContent()

テンプレートのコンテンツをオブジェクトのインスタンスとして読み込み、コンテンツのルート要素を返します。

(継承元 FrameworkTemplate)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
RegisterName(String, Object)

現在の名前スコープに新しい名前とオブジェクトのペアを登録します。

(継承元 FrameworkTemplate)
Seal()

テンプレートをロックし、変更できないようにします。

(継承元 FrameworkTemplate)
ShouldSerializeResources(XamlDesignerSerializationManager)

シリアル化プロセスが、このクラスのインスタンスの Resources プロパティの値をシリアル化する必要があるかどうかを示す値を返します。

(継承元 FrameworkTemplate)
ShouldSerializeVisualTree()

シリアル化プロセスが、このクラスのインスタンスの VisualTree プロパティの値をシリアル化する必要があるかどうかを示す値を返します。

(継承元 FrameworkTemplate)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
UnregisterName(String)

XAML 名前スコープから名前とオブジェクトのマッピングを削除します。

(継承元 FrameworkTemplate)
ValidateTemplatedParent(FrameworkElement)

テンプレートが適用される親が、null 以外の ItemsPresenter オブジェクトであるか検証します。

VerifyAccess()

呼び出し元のスレッドがこの DispatcherObject にアクセスできるように強制します。

(継承元 DispatcherObject)

明示的なインターフェイスの実装

INameScope.FindName(String)

指定された識別名を持つオブジェクトを返します。

(継承元 FrameworkTemplate)
IQueryAmbient.IsAmbientPropertyAvailable(String)

指定されたアンビエント プロパティを現在のスコープで使用できるかどうかを照会します。

(継承元 FrameworkTemplate)

適用対象