Export (0) Print
Expand All

GridViewColumn.CellTemplateSelector Property

Gets or sets a DataTemplateSelector that determines the template to use to display cells in a column.

Namespace:  System.Windows.Controls
Assembly:  PresentationFramework (in PresentationFramework.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation

public DataTemplateSelector CellTemplateSelector { get; set; }
<object>
  <object.CellTemplateSelector>
    <MyDataTemplateSelectorImplementation .../>
  </object.CellTemplateSelector>
</object>
<object CellTemplateSelector="{ResourceExtension DataTemplateSelectorClassKey}"/>

XAML Values

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.

Property Value

Type: System.Windows.Controls.DataTemplateSelector
A DataTemplateSelector that provides DataTemplate selection for column cells. The default is null.

Identifier field

CellTemplateSelectorProperty

Metadata properties set to true

None

The following properties all bind to and display the content of a column cell, and are listed here in their order of precedence, from highest to lowest:

The following example shows how to set the CellTemplateSelector property.


<ListView ItemsSource="{Binding Source={StaticResource EmployeeData}, 
                                        XPath=Employee}">
  <ListView.View>       
    <GridView>
      <GridViewColumn Header="First Name"
               DisplayMemberBinding="{Binding XPath=FirstName}" />
      <GridViewColumn Header="Last Name"  
               CellTemplate="{StaticResource LastNameCellTemplate}"/>
      <GridViewColumn Header="Favorite City" 
               CellTemplateSelector="{DynamicResource 
                                      FavoriteCityTemplateSelector}"/>
    </GridView>
  </ListView.View>    
</ListView>

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft