Grid control and data binding in WPF

The GridData control from Syncfusion was built for data binding applications.  But, sometimes you need the flexibility of our Grid control.   Here is a simple sample showing how you can implement basic data binding and updating via our Grid control. 

In this sample, we are handling the cell editing complete event to update the data source with a very simple validation check. 

Download the sample here.

 void grid_CurrentCellEditingComplete(object sender, Syncfusion.Windows.ComponentModel.SyncfusionRoutedEventArgs args)
            if (vm.Table.Rows.Count < this.grid.Model.RowCount - 1)
            int rowIndex = this.grid.CurrentCell.RowIndex;
            int colIndex = this.grid.CurrentCell.ColumnIndex;
            if (colIndex == 1)
                vm.Table.Rows[rowIndex - 1][colIndex] = this.grid.Model[rowIndex, colIndex].CellValue.ToString();
            else if (colIndex == 2 || colIndex == 0)
                if (!this.grid.Model[rowIndex, colIndex].CellValue.ToString().IsNumeric())
                    this.grid.Model[rowIndex, colIndex].CellValue = "0";
                vm.Table.Rows[rowIndex - 1][colIndex] = int.Parse(this.grid.Model[rowIndex, colIndex].CellValue.ToString());


Share this post:

Related Posts

Leave a comment