Represents a DataGrid column that hosts template-specified content in its cells.
Namespace:
System.Windows.Controls
Assembly:
System.Windows.Controls.Data (in System.Windows.Controls.Data.dll)
Visual Basic (Declaration)
Public Class DataGridTemplateColumn _
Inherits DataGridColumn
Dim instance As DataGridTemplateColumn
public class DataGridTemplateColumn : DataGridColumn
XAML Object Element Usage
<data:DataGridTemplateColumn .../>
XAML Values
- data:
A prefix that is defined to map the XML namespace for the System.Windows.Controls.Data assembly and the System.Windows.Controls CLR namespace.
The DataGridTemplateColumn type enables you to create your own column types by specifying the cell templates used to display values and enable editing. Set the CellTemplate property to specify the contents of cells that display values, but do not allow editing. Set the CellEditingTemplate property to specify the contents of cells in editing mode. If you set the column IsReadOnly property to true, the CellEditingTemplate property value is never used.
The following code example demonstrates how to specify and configure a DataGridTemplateColumn in XAML. This example is part of a larger example available in the DataGrid class overview.
<data:DataGrid x:Name="dataGrid5"
Height="125" Margin="0,5,0,10"
AutoGenerateColumns="False"
RowBackground="Azure"
AlternatingRowBackground="LightSteelBlue">
<data:DataGrid.Columns>
<!-- Name Column -->
<data:DataGridTemplateColumn Header="Name">
<data:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock Padding="5,0,5,0"
Text="{Binding FirstName}"/>
<TextBlock Text="{Binding LastName}"/>
</StackPanel>
</DataTemplate>
</data:DataGridTemplateColumn.CellTemplate>
<data:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBox Text="{Binding FirstName}" BorderThickness="0"/>
<TextBox Text="{Binding LastName}" BorderThickness="0"/>
</StackPanel>
</DataTemplate>
</data:DataGridTemplateColumn.CellEditingTemplate>
</data:DataGridTemplateColumn>
<!-- Address Column -->
<data:DataGridTextColumn
Header="Address" Width="300"
Binding="{Binding Address}" />
</data:DataGrid.Columns>
</data:DataGrid>
System..::.Object
System.Windows..::.DependencyObject
System.Windows.Controls..::.DataGridColumn
System.Windows.Controls..::.DataGridTemplateColumn
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.
Reference