ItemsControl.ItemsPanel Property
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Gets or sets the template that defines the panel that controls the layout of items.
public:
property ItemsPanelTemplate ^ ItemsPanel { ItemsPanelTemplate ^ get(); void set(ItemsPanelTemplate ^ value); };
ItemsPanelTemplate ItemsPanel();
void ItemsPanel(ItemsPanelTemplate value);
public ItemsPanelTemplate ItemsPanel { get; set; }
var itemsPanelTemplate = itemsControl.itemsPanel;
itemsControl.itemsPanel = itemsPanelTemplate;
Public Property ItemsPanel As ItemsPanelTemplate
<itemsControl>
<itemsControl.ItemsPanel>
singlePanelTemplate
</itemsControl.ItemsPanel>
</itemsControl>
- or -
<itemsControl ItemsPanel="resourceReferenceToPanelTemplate"/>
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.
Subtypes of ItemsControl may use different default ItemsPanelTemplates. For example, ListViews by default use an ItemsStackPanel. Using a different type may cause unexpected behavior; for example using a plain StackPanel as the ListView's ItemsPanel can regress Narrator behavior during drag and drop.
Replace the default panel used in a ListView with an ItemsStackPanel that has its Orientation changed to Horizontal.
<ListView>
<x:String>Hello</x:String>
<x:String>World</x:String>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<ItemsStackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ListView>
Note
ComboBox uses a CarouselPanel as its ItemsPanel. Using a different panel as the ItemsPanel of ComboBox is not supported and might result in undesired behavior.
Product | Versions |
---|---|
WinRT | Build 10240, Build 10586, Build 14383, Build 15063, Build 16299, Build 17134, Build 17763, Build 18362, Build 19041, Build 20348, Build 22000, Build 22621, Build 26100 |