最終更新:2020-04-06 (月) 16:52:11 (1474d)  

System.Windows.Controls.ItemsControl
Top / System.Windows.Controls.ItemsControl

https://docs.microsoft.com/ja-jp/dotnet/api/system.windows.controls.itemscontrol?view=netframework-4.8

  • 複数の子要素(Itemsプロパティ)を持つ
  • 子要素はUIElementオブジェクト

ItemsControl.Items?

派生クラス

  • System.Windows.Controls.HeaderedItemsControl?
  • System.Windows.Controls.TreeView?
  • System.Windows.Controls.Primitives.DataGridCellsPresenter?
  • System.Windows.Controls.Primitives.DataGridColumnHeadersPresenter?
  • System.Windows.Controls.Primitives.MenuBase?
  • System.Windows.Controls.Primitives.Selector
  • System.Windows.Controls.Primitives.StatusBar?
  • System.Windows.Controls.Ribbon.RibbonContextualTabGroupItemsControl?
  • System.Windows.Controls.Ribbon.RibbonControlGroup?
  • System.Windows.Controls.Ribbon.RibbonGallery?
  • System.Windows.Controls.Ribbon.RibbonQuickAccessToolBar?
  • System.Windows.Controls.Ribbon.RibbonTabHeaderItemsControl?

外観

Control.Template (型:System.Windows.Controls.ControlTemplate)

  • コントロール自体のカスタマイズ
    <ItemsControl.Template>
        <ControlTemplate TargetType="ItemsControl">
            <Border BorderThickness="1"
                    BorderBrush="Black"
                    Background="Azure">
                <ItemsPresenter Margin="10" />
            </Border>
        </ControlTemplate>
    </ItemsControl.Template>

ItemsControl.ItemsPanel (型:System.Windows.Controls.ItemsPanelTemplate)

  • コレクション項目をどのようにレイアウトするかを決定
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <!-- (1) <StackPanel Orientation="Vertical" /> --> 
            <!-- (2) <WrapPanel Orientation="Horizontal" /> -->
            <!-- (3) <Grid /> -->
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>

ItemsControl.ItemContainerStyle?

  • コレクションのコンテナのカスタマイズ
  • ListBoxが生成するコンテナー要素はListBoxItem?
  • ComboBoxが生成するコンテナー要素はComboBoxItem?

ItemsControl.ItemTemplate (型:System.Windows.DataTemplate)

  • 項目ごとの外観のカスタマイズ
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <TextBlock Margin="5">
                <Run Text="No." />
                <Run Text="{Binding Number}" />
                <LineBreak />
                <Run Text="Name:" />
                <Run Text="{Binding Name}" FontSize="15" />
            </TextBlock>
        </DataTemplate>
    </ItemsControl.ItemTemplate>

関連

参考