Skip to main content
Version: 11.0.x


You can use this column type to customise the display and editing for a data grid column.

There are two data templates which you define as attached properties:

Data TemplateDescription
CellTemplate The display (not being edited) presentation of the column value.
CellEditingTemplate The editing template for the column value.

If you do not set a editing template, the column will stay read-only.


This example adds a numeric up-down control when the age property for a person is being edited:

<Window ...
xmlns:model="using:AvaloniaControls.Models" >

<DataGrid Margin="20" ItemsSource="{Binding People}"
BorderThickness="1" BorderBrush="Gray">
<DataGridTextColumn Header="First Name" Width="2*"
Binding="{Binding FirstName}" />
<DataGridTextColumn Header="Last Name" Width="2*"
Binding="{Binding LastName}" />

<DataGridTemplateColumn Header="Age">
<DataTemplate DataType="model:Person">
<TextBlock Text="{Binding AgeInYears, StringFormat='{}{0} years'}"
VerticalAlignment="Center" HorizontalAlignment="Center" />
<DataTemplate DataType="model:Person">
<NumericUpDown Value="{Binding AgeInYears}"
FormatString="N0" Minimum="0" Maximum="120"

C# View Model
using AvaloniaControls.Models;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace AvaloniaControls.ViewModels
public class MainWindowViewModel : ViewModelBase
public ObservableCollection<Person> People { get; }

public MainWindowViewModel()
var people = new List<Person>
new Person("Neil", "Armstrong", 55),
new Person("Buzz", "Lightyear", 38),
new Person("James", "Kirk", 44)
People = new ObservableCollection<Person>(people);
C# Item Class
public class Person
public string FirstName { get; set; }
public string LastName { get; set; }
public int AgeInYears { get; set; }

public Person(string firstName , string lastName, int ageInYears)
FirstName = firstName;
LastName = lastName;
AgeInYears = ageInYears;

More Information


For the complete API documentation about this control, see here.


View the source code on GitHub DataGridTemplateColumn.cs