Gets or sets the cell template selector.

Namespace: Dapfor.Wpf.Controls
Assembly: Dapfor.Wpf (in Dapfor.Wpf.dll) Version: (


public DataTemplateSelector CellTemplateSelector { get; set; }
Visual Basic
Public Property CellTemplateSelector As DataTemplateSelector
Visual C++
property DataTemplateSelector^ CellTemplateSelector {
	DataTemplateSelector^ get ();
	void set (DataTemplateSelector^ value);
member CellTemplateSelector : DataTemplateSelector with get, set

Property Value

Type: DataTemplateSelector
The cell template selector.


Different data templates can be set in different columns. These templates are applied to all cells of the column where a template is set. However, sometimes you need to use different templates for different rows. For this purpose Column class provides Column.CellTemplateSelector property that can be used to set a data template selector in run-time. An example of data template selector usage is shown below:

 Copy imageCopy
class CustomTemplateSelector : DataTemplateSelector
    public DataTemplate Template1 { get; set; }
    public DataTemplate Template2 { get; set; }
    public override DataTemplate SelectTemplate(object item, DependencyObject container)
        var cell = item as Cell;
        if (cell != null)
            return cell.Row.VisibleIndex == 2 ? Template2 : Template1;
        return base.SelectTemplate(item, container);
 Copy imageCopy
  <TestApplication:MyCollection x:Key="someCollection" /> 
  <TestApplication:IntToFlagValueConverter x:Key="intToFlagConverter"/> 
  <BitmapImage x:Key="image" UriSource="/Images/dapfor.ico" DecodePixelWidth="16" DecodePixelHeight="16" /> 

  <!--Data Template 1--> 
  <DataTemplate x:Key="Template1"> 
       <Image Source="{Binding Path=Value, Converter={StaticResource intToFlagConverter}}"/> 
       <Grid Grid.Column="1"> <Ellipse Fill="Green"/> 
         <TextBlock Text="{Binding Path=Text}" HorizontalAlignment="Center" Foreground="Red"/> 
         <ColumnDefinition Width="Auto"/> 

   <!--Data Template 2--> 
   <DataTemplate x:Key="Template2"> 
     <StackPanel Orientation="Horizontal"> 
       <Image Source="{StaticResource image}"/> 
       <Image Source="{StaticResource image}"/> 
       <TextBlock Text="{Binding Path=Text}" Margin="5,0,5,0"/> 
       <Image Source="{StaticResource image}"/> 
       <Image Source="{StaticResource image}"/> 

   <!--DataTemplate selector--> 
   <TestApplication:CustomTemplateSelector x:Key="tempateSelector" 
                                           Template1="{StaticResource Template1}" 
                                           Template2="{StaticResource Template2}"/> 

<df:GridControl Name="grid" ItemsSource="{StaticResource someCollection}"> 
        <df:Column Id="Value1" Title="Column 0" CellTemplateSelector="{StaticResource tempateSelector}" Width="100" /> 
        <df:Column Id="Value2" Title="Column 1" Width="100" /> 

See Also