FlexGrid for WinRT
CellTemplate Property
Example 

Gets or sets the template used to display the contents of a cell that is not in editing mode.
Syntax
'Declaration
 
Public Property CellTemplate As Windows.UI.Xaml.DataTemplate
public Windows.UI.Xaml.DataTemplate CellTemplate {get; set;}
Remarks

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.

Example
The XAML below creates a column with custom templates for cell display and editing (notice that in addition to the templates, the XAML specifies a Binding for the column):
<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>
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

Column Class
Column Members

 

 


Copyright © GrapeCity, inc. All rights reserved.

Product Support Forum  |   Documentation Feedback