C1.Silverlight.FlexGrid.5 Assembly > C1.Silverlight.FlexGrid Namespace > Column Class : CellTemplate Property |
'Declaration Public Property CellTemplate As System.Windows.DataTemplate
public System.Windows.DataTemplate CellTemplate {get; set;}
The CellTemplate and CellEditingTemplateproperties work like the equivalent ones in the Microsoft DataGrid for Silverlight/WPF.
They can be defined in XAML and are used to create the visual elements that represent the cells in the column.
CellTemplate creates cells in regular mode and CellEditingTemplate creates cells in edit mode.
Note that in most cases you should specify a Binding for the column even if it has custom templates. The templates are used to show and edit the values on the grid, but the column binding is still used when getting data values for other purposes including clipboard and export support.
<c1:C1FlexGrid x:Name="_fgTemplated"> <c1:C1FlexGrid.Columns> <!-- add a templated column --> <!-- Binding used only for clipboard and export support --> <c1:Column Binding="{Binding Name}" Header="Template" Width="200"> <!-- template for cells in display mode --> <c1:Column.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Name}" Foreground="Green" FontWeight="Bold" /> </DataTemplate> </c1:Column.CellTemplate> <!-- template for cells in edit mode --> <c1:Column.CellEditingTemplate> <DataTemplate> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Image Source="edit_icon.png" Grid.Column="0" /> <TextBox Text="{Binding Name, Mode=TwoWay}" Grid.Column="1" /> </Grid> </DataTemplate> </c1:Column.CellEditingTemplate> </c1:Column> </c1:C1FlexGrid.Columns> </c1:C1FlexGrid>