DataTemplateSelector.SelectTemplateCore(Object, DependencyObject) method

Applies to Windows and Windows Phone

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

Syntax


protected virtual DataTemplate SelectTemplateCore(
  object item, 
  DependencyObject container
)

Parameters

item

Type: System.Object [.NET] | Platform::Object [C++]

The item to return a template for.

container

Type: DependencyObject

The parent container for the templated item.

Return value

Type: DataTemplate

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

Remarks

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.

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.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Controls
Windows::UI::Xaml::Controls [C++]

Metadata

Windows.winmd

See also

DataTemplateSelector
DataTemplate
SelectTemplateCore(Object)
Adding ListView and GridView controls

 

 

Show:
© 2014 Microsoft