Numerical Column
The DataGridNumericalColumn
represents only numerical values.
The following example shows how to generate a DataGridNumericalColumn
.
-
First, create the business object.
Create the Data Model
public class Data { public string Product { get; set; } public int Amount { get; set; } }
-
The next step is to create some sample data.
Create Sample Data
public MainPage() { this.InitializeComponent(); this.DataContext = new List<Data>() { new Data { Product = "Jacket", Amount = 5}, new Data { Product = "Jeans", Amount = 3}, new Data { Product = "T-Shirt", Amount = 5}, new Data { Product = "Socks", Amount = 10} }; }
-
The final step is to bind the
ItemsSource
property of the DataGrid and manually declare theDataGridNumericalColumn
column. To associate each column with the relevant property from the model, the example uses thePropertyName
property.Define PropertyName in XAML
Numerical Column<telerikGrid:RadDataGrid UserEditMode="Inline" ItemsSource="{Binding}" AutoGenerateColumns="False" Height="250" Width="300"> <telerikGrid:RadDataGrid.Columns> <telerikGrid:DataGridTextColumn PropertyName="Product" Header="Product"/> <telerikGrid:DataGridNumericalColumn PropertyName="Amount" Header="Amount"/> </telerikGrid:RadDataGrid.Columns> </telerikGrid:RadDataGrid>