DataTemplateSelector.SelectTemplateCore Method

Definition

Overloads

SelectTemplateCore(Object)

When implemented by a derived class, returns a specific DataTemplate for a given item or container.

SelectTemplateCore(Object, DependencyObject)

When implemented by a derived class, returns a specific DataTemplate for a given item or container.

SelectTemplateCore(Object)

When implemented by a derived class, returns a specific DataTemplate for a given item or container.

C#
[Windows.Foundation.Metadata.Overload("SelectTemplateForItemCore")]
protected virtual DataTemplate SelectTemplateCore(object item);

Parameters

item
Object

The item to return a template for.

Returns

The template to use for the given item and/or container.

Attributes

Remarks

If your ItemsControl.ItemsPanel is an ItemsStackPanel or ItemsWrapGrid, provide an override for the SelectTemplateCore(Object) method. If the ItemsPanel is a different panel, such as VirtualizingStackPanel or WrapGrid, provide an override for the SelectTemplateCore(Object, DependencyObject) method.

Note

In Windows 8.1, ItemsStackPanel is the default ItemsPanel for ListView, and ItemsWrapGrid is the default ItemsPanel for GridView.

See also

Applies to

WinRT Build 26100 and other versions
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

SelectTemplateCore(Object, DependencyObject)

When implemented by a derived class, returns a specific DataTemplate for a given item or container.

C#
protected virtual DataTemplate SelectTemplateCore(object item, DependencyObject container);

Parameters

item
Object

The item to return a template for.

container
DependencyObject

The parent container for the templated item.

Returns

The template to use for the given item and/or container.

Remarks

Important

This overload of SelectTemplateCore should not be used. It will not be called by certain controls like TreeView and ItemsRepeater where the template creates the container as well as the item. Please use the overload without the container instead.

Most implementations will choose to implement the selection logic based on the value of either item or container, not both. Implementations should still pass the unused parameter as-is to base.

See also

Applies to

WinRT Build 26100 and other versions
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