Windows apps
Collapse the table of content
Expand the table of content
Information
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.

HeaderedItemsControl.HeaderTemplateSelector Property

 

Gets or sets the object that provides custom selection logic for a template used to display the header of each item.

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

[BindableAttribute(true)]
public DataTemplateSelector HeaderTemplateSelector { get; set; }

Property Value

Type: System.Windows.Controls.DataTemplateSelector

A data template selector. The default is null.

Typically, you create a DataTemplateSelector when you have more than one DataTemplate for the same type of objects and you want to supply your own logic to choose a DataTemplate to apply based on the properties of each data object. Note that if you have objects of different types you can set the DataType property on the DataTemplate. If you do that, then there is no need to create a DataTemplateSelector. Furthermore, if you have objects of the same type but with different properties, you can also consider using a DataTrigger or a data converter. For more information, see Data Templating Overview.

To create a template selector, create a class that inherits from DataTemplateSelector and override the SelectTemplate method. After your class is defined, you can assign an instance of the class to the template selector property of your element.

If both the HeaderTemplateSelector and the HeaderTemplate properties are set, the template selector property is ignored.

<object HeaderTemplateSelector="{ResourceExtension DataTemplateSelectorClassKey}"/>

<object>
  <object.HeaderTemplateSelector>
    <MyDataTemplateSelectorImplementation .../>
  </object.HeaderTemplateSelector>
</object>

MyDataTemplateSelectorImplementation

A class derived from DataTemplateSelector that implements a practical SelectTemplate override. For information about how to map your custom class, see XAML Namespaces and Namespace Mapping for WPF XAML.

ResourceExtension

One of the following: StaticResource, or DynamicResource. See XAML Resources.

DataTemplateSelectorClassKey

The key that identifies the selector implementation being requested. The key refers to a derived class that implements a practical SelectTemplate override. For information about how to map your custom class, see XAML Namespaces and Namespace Mapping for WPF XAML. You can also programmatically add an instance of your DataTemplateSelector class as a resource to a resource dictionary.

Identifier field

HeaderTemplateSelectorProperty

Metadata properties set to true

None

.NET Framework
Available since 3.0
Return to top
Show:
© 2016 Microsoft