WPF Controls: Items controls

The controls that inherit from ItemsControl are controls that support a collection of objects.

These controls can be used to display a collection of objects on the screen. For example, controls like ListBox and ComboBox can be used to allow the user to select an object from a collection.

listbox

Items Controls

Items controls are everything that derives from System.Windows.Controls.ItemsControl.

  • System.Windows.Controls.HeaderedItemsControl
  • 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
  • System.Windows.Controls.TreeView

HeaderedItemsControl

The HeaderedItemsControl control is a control that supports a collection of items with headers.

DataGridCellsPresenter

The DataGridCellsPresenter control is used by the Grid control template to display the cells.

DataGridColumnHeadersPresenter

The DataGridCellsPresenter control is used by the Grid control template to display the header cells.

MenuBase

The MenuBase control is the base class for the Menu and ContextMenu controls.

ContextMenu

The ContextMenu control is the menu that shows up when you right-click the element.

<Label Content="red">
    <Label.ContextMenu>
        <ContextMenu>
            <MenuItem Header="_Copy" Command="{Binding CopyCommand}" />
        </ContextMenu>
    </Label.ContextMenu>
</Label>

Menu

The Menu control allows you to nest MenuItems forming a menu that can run commands.

<Menu>
    <MenuItem Header="_File">
        <MenuItem Header="Quit" Command="{Binding QuitCommand}" />
    </MenuItem>
</Menu>

Selector

The Selector control is the base class for:

  • System.Windows.Controls.ComboBox
  • System.Windows.Controls.ListBox
  • System.Windows.Controls.Primitives.MultiSelector
  • System.Windows.Controls.DataGrid
  • System.Windows.Controls.Ribbon.Ribbon
  • System.Windows.Controls.TabControl

ComboBox

The ComboBox control allows you to select a single option from the collection.

<ComboBox>
    <ComboBoxItem Content="Development" />
    <ComboBoxItem Content="Test" />
</ComboBox>

To bind an enum to a ComboBox you can use this approach posted on Stack Overflow.

ListBox

The ListBox control allows you to select one or more items from a collection.

<ListBox SelectionMode="Multiple">
    <ListBoxItem Content="Dev" />
    <ListBoxItem Content="Test" />
</ListBox>

DataGrid

The DataGrid control can be used to show tabular data. By default it auto generate columns by reading the public properties of the object.

<DataGrid AutoGenerateColumns="True" ItemsSource="{Binding Items}" />

TabControl

The TabControl control allows you to place controls in different tabs.

<TabControl>
    <TabItem Header="Home">
        Home Content
    </TabItem>
    <TabItem Header="Second">
        Second Content
    </TabItem>
</TabControl>

StatusBar

The StatusBar control can contain a collection of controls that will be displayed.

<StatusBar>
    <StatusBarItem>
        <Label Content="Status..." />
    </StatusBarItem>
    <StatusBarItem>
        <Label Content="10/10/2020 10:10" />
    </StatusBarItem>
</StatusBar>

TreeView

The TreeView control allows to bind items with hierarchy.

<TreeView ItemsSource="{Binding Games}">
    <TreeView.ItemTemplate>
        <HierarchicalDataTemplate ItemsSource="{Binding Characters}">
            <TextBlock Text="{Binding Name}" />
        </HierarchicalDataTemplate>
    </TreeView.ItemTemplate>
</TreeView>

treeview

Advertisements

2 thoughts on “WPF Controls: Items controls

  1. Pingback: The MVVM pattern in WPF | Coding Wise

  2. ct2600.org

    See the reply by Nabuch for the winner! Yes folks, THERE’S awesome, full-featured VoIP software
    out there, as well as the big surprise is the fact that no one has heard of it!

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s