C# Tips

C# Tip Article

NumericUpDown control in WPF DataGrid


How to add NumericUpDown control in WPF DataGrid?

How to use

One way of adding NumericUpDown feature in WPF DataGrid is to use Extended WPF Toolkit. Extended WPF Toolkit provides various WPF extended controls, which can be found in github or nuget.

  • Install Extended.Wpf.Toolkit NuGet package from VS Package Manager Console.
    PM> Install-Package Extended.Wpf.Toolkit -Version 3.3.0
  • In your XAML, add namespace for the WPF Toolkit assembly.
    <Window x:Class="MyApp.MainWindow"
  • In your XAML, add wpfToolkit:IntegerUpDown in DataGridTemplateColumn.CellTemplate of a DataGrid.
    <DataGrid x:Name="dg">
    		<DataGridTextColumn Header="Id" Binding="{Binding Path=Id}"/>
    		<DataGridTemplateColumn Header="Age">
    					<wpfToolkit:IntegerUpDown Value="{Binding Path=Age, UpdateSourceTrigger=PropertyChanged}" />