.NET Framework Class Library
GridViewColumn..::.CellTemplateSelector Property

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

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
Syntax

Visual Basic (Declaration)
Public Property CellTemplateSelector As DataTemplateSelector
Visual Basic (Usage)
Dim instance As GridViewColumn
Dim value As DataTemplateSelector

value = instance.CellTemplateSelector

instance.CellTemplateSelector = value
C#
public DataTemplateSelector CellTemplateSelector { get; set; }
Visual C++
public:
property DataTemplateSelector^ CellTemplateSelector {
    DataTemplateSelector^ get ();
    void set (DataTemplateSelector^ value);
}
JScript
public function get CellTemplateSelector () : DataTemplateSelector
public function set CellTemplateSelector (value : DataTemplateSelector)
XAML Property Element Usage
<object>
  <object.CellTemplateSelector>
    <MyDataTemplateSelectorImplementation .../>
  </object.CellTemplateSelector>
</object>
XAML Attribute Usage
<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.

ResourceExtension

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

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. 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 nullNothingnullptra null reference (Nothing in Visual Basic).
Dependency Property Information

Identifier field

CellTemplateSelectorProperty

Metadata properties set to true

None

Remarks

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:

Examples

The following example shows how to set the CellTemplateSelector property.

XAML
<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>
Platforms

Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Version Information

.NET Framework

Supported in: 3.5, 3.0
See Also

Reference

Tags :


Page view tracker