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)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public DataTemplateSelector CellTemplateSelector { get; set; }
/** @property */
public DataTemplateSelector get_CellTemplateSelector ()

/** @property */
public void set_CellTemplateSelector (DataTemplateSelector value)

public function get CellTemplateSelector () : DataTemplateSelector

public function set CellTemplateSelector (value : DataTemplateSelector)

<object>
  <object.CellTemplateSelector>
    <MyDataTemplateSelectorImplementation .../>
  </object.CellTemplateSelector>
</object>
<object CellTemplateSelector="{ResourceExtensionDataTemplateClassKey}"/>
 MyDataTemplateSelectorImplementation  A subclass of DataTemplateSelector that implements a practical SelectTemplate override. For information about how to map your custom class, see XAML Namespaces and Namespace Mapping.  ResourceExtension   StaticResource or DynamicResource. StaticResource typically provides better performance.  DataTemplateClassKey  An x:Key resource key that refers to a custom DataTemplateSelector subclass that implements a practical SelectTemplate override. For information about how to map your custom class, see XAML Namespaces and Namespace Mapping. You can also programmatically add an instance of your DataTemplateSelector class as a resource to the application resource dictionary. 

Property Value

A DataTemplateSelector that provides DataTemplate selection for column cells. The default value is a null reference (Nothing in Visual Basic).

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>

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

ADD
Show: