System.Windows.Controls Nam ...


.NET Framework Class Library for Silverlight
DataGridTemplateColumn Class

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)
Syntax

Visual Basic (Declaration)
Public Class DataGridTemplateColumn _
    Inherits DataGridColumn
Visual Basic (Usage)
Dim instance As DataGridTemplateColumn
C#
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.

Remarks

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.

Examples

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.

XAML
<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>
Inheritance Hierarchy

System..::.Object
  System.Windows..::.DependencyObject
    System.Windows.Controls..::.DataGridColumn
      System.Windows.Controls..::.DataGridTemplateColumn
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Tags :


Page view tracker