# C1.WPF.FlexGrid.Column.CellTemplate

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="C1_WPF_FlexGrid_Column_CellTemplate_" data-uid="C1.WPF.FlexGrid.Column.CellTemplate*">CellTemplate Property
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="C1_WPF_FlexGrid_Column_CellTemplate_" data-uid="C1.WPF.FlexGrid.Column.CellTemplate*"></a>
<h4 id="C1_WPF_FlexGrid_Column_CellTemplate" data-uid="C1.WPF.FlexGrid.Column.CellTemplate">CellTemplate</h4>
<div class="markdown level1 summary"><p>Gets or sets the template used to display the contents of a cell that is not
in editing mode.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public DataTemplate CellTemplate { get; set; }</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Property CellTemplate As DataTemplate</code></pre>
</div>
<h5 id="C1_WPF_FlexGrid_Column_CellTemplate_remarks">Remarks</h5>
<div class="markdown level1 remarks">   <p>The <b>CellTemplate</b> and <b>CellEditingTemplate</b>properties work like 
the equivalent ones in the Microsoft DataGrid for Silverlight/WPF.</p>
   <p>They can be defined in XAML and are used to create the visual elements that 
represent the cells in the column.</p>
   <p>
       <b>CellTemplate</b> creates cells in regular mode and <b>CellEditingTemplate</b>
creates cells in edit mode.</p>
   <p>Note that in most cases you should specify a <a class="xref" href="C1.WPF.FlexGrid.Column.Binding.html#C1_WPF_FlexGrid_Column_Binding">Binding</a> 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.</p>
</div>
<h5 id="C1_WPF_FlexGrid_Column_CellTemplate_examples">Examples</h5>
<p>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 <a class="xref" href="C1.WPF.FlexGrid.Column.Binding.html#C1_WPF_FlexGrid_Column_Binding">Binding</a>
for the column):</p>
<pre><code class="lang-csharp">&lt;c1:C1FlexGrid x:Name="_fgTemplated"&gt;
  &lt;c1:C1FlexGrid.Columns&gt;

    &lt;!-- add a templated column --&gt;
    &lt;!-- Binding used only for clipboard and export support --&gt;
    &lt;c1:Column Binding="{Binding Name}" Header="Template" Width="200"&gt;

      &lt;!-- template for cells in display mode --&gt;
      &lt;c1:Column.CellTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;TextBlock Text="{Binding Name}" Foreground="Green" FontWeight="Bold" /&gt;
        &lt;/DataTemplate&gt;
      &lt;/c1:Column.CellTemplate&gt;

      &lt;!-- template for cells in edit mode --&gt;
      &lt;c1:Column.CellEditingTemplate&gt;
        &lt;DataTemplate&gt;
          &lt;Grid&gt;
            &lt;Grid.ColumnDefinitions&gt;
              &lt;ColumnDefinition Width="Auto" /&gt;
              &lt;ColumnDefinition Width="*" /&gt;
            &lt;/Grid.ColumnDefinitions&gt;
            &lt;Image Source="edit_icon.png" Grid.Column="0" /&gt;
            &lt;TextBox Text="{Binding Name, Mode=TwoWay}" Grid.Column="1" /&gt;
          &lt;/Grid&gt;
        &lt;/DataTemplate&gt;
      &lt;/c1:Column.CellEditingTemplate&gt;
    &lt;/c1:Column&gt;
  &lt;/c1:C1FlexGrid.Columns&gt;
&lt;/c1:C1FlexGrid&gt;</code></pre>

</div>
