New to Telerik UI for WinUI? Download free 30-day trial

Text Column

A DataGridTextColumn column converts the content of each associated cell to a System.String object.

A DataGridTextColumn has better performance than a DataGridTemplateColumn.

Key Properties

  • CellContentFormat: Gets or sets the custom format for each cell value. The String.Format routine is used and the format passed should be in the form required by this method.


The following example shows how to generate DataGridTextColumn manually. First we need to create our business object.

Example 1: Create Data model

public class Data 
    public string Country { get; set; } 
    public string Capital { get; set; } 
The next step is to create sample data.

Example 2: Create Sample Data

public MainPage() 
    this.DataContext = new List<Data> 
        new Data { Country = "Columbia", Capital = "Bogota"}, 
        new Data { Country = "Germany", Capital = "Berlin"}, 
        new Data { Country = "Italy", Capital = "Rome"}, 
        new Data { Country = "France", Capital = "Paris" }, 
        new Data { Country = "Bulgaria", Capital = "Sofia" },  
In this example we have two columns. As you can see we have used the CellContentStyle property to apply a style to the first column and the CellContentFormat property to format the content of the second column. We have used the PropertyName property to associate each column with the relevant property from our model.

Example 3: Defining in XAML

<telerikGrid:RadDataGrid UserEditMode="Inline" x:Name="grid" AutoGenerateColumns="False" ItemsSource="{Binding}" VerticalAlignment="Center" Width="300"> 
        <telerikGrid:DataGridTextColumn PropertyName="Country" Header="Country"> 
                <Style TargetType="TextBlock"> 
                    <Setter Property="Foreground" Value="Red"/> 
                    <Setter Property="FontStyle" Value="Italic"/> 
                    <Setter Property="HorizontalAlignment" Value="Center"/> 
                    <Setter Property="VerticalAlignment" Value="Center"/> 
        <telerikGrid:DataGridTextColumn PropertyName="Capital" Header="Capital" CellContentFormat="{}{0} city"/> 

Figure 1: Text Column

Text Column Style And Format

In this article
Not finding the help you need?