Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ItemsControl.ItemsPanel Property


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Gets or sets the template that defines the panel that controls the layout of items.

Namespace:   System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)

public ItemsPanelTemplate ItemsPanel { get; set; }

Property Value

Type: System.Windows.Controls.ItemsPanelTemplate

An ItemsPanelTemplate that defines the panel to use for the layout of the items. The default value for the ItemsControl is an ItemsPanelTemplate that specifies a StackPanel.

For the ListBox, the default ItemsPanelTemplate specifies the VirtualizingStackPanel. For MenuItem, the default uses WrapPanel. For StatusBar, the default uses DockPanel.

To affect the layout of the items in an ItemsControl, you use this property to specify a ItemsPanelTemplate.

The ItemsControl provides great flexibility for visual customization and provides many styling and templating properties. You use the ItemContainerStyle property or the ItemContainerStyleSelector property to set a style to affect the appearance of the elements that contain the data items. For example, for ListBox, the generated containers are ListBoxItem controls; for ComboBox, they are ComboBoxItem controls. If you are using grouping on your control, you can use the GroupStyle or GroupStyleSelector property. To specify the visualization of the data objects, use the ItemTemplate or the ItemTemplateSelector property. For more information, see Data Templating Overview.

Identifier field


Metadata properties set to true


To create a horizontal ListBox, you can create a template that specifies a horizontal StackPanel and set it as the ItemsPanel property. The following example shows a ListBox Style that creates a horizontal ListBox.

<Style TargetType="ListBox">
  <Setter Property="ItemsPanel">
        <StackPanel Orientation="Horizontal"

The following example uses a ControlTemplate to create a horizontal ListBox that has rounded corners. In this example, instead of setting the ItemsPanel property as in previous example, the horizontal StackPanel is specified within the ControlTemplate. The IsItemsHost property is set to true on the StackPanel, indicating that the generated items should go in the panel. When you specify it this way, the ItemsPanel cannot be replaced by the user of the control without using a ControlTemplate. Therefore, only do this if you know you would not want the panel to be replaced without the use of a template.

Alternatively, you can do the following to achieve the same results. In this case, the ItemsPresenter creates the panel for the layout of the items based on what is specified by the ItemsPanelTemplate.

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
© 2018 Microsoft