Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do editable data grid in wpf using mvvm?

Tags:

mvvm

wpf

datagrid

I want to use a editable data grid, to add, edit data. Is it possible with wpf? Can some one give an the example?

like image 401
SNS Avatar asked Oct 29 '13 04:10

SNS


People also ask

How do you make an editable grid in WPF?

You can set the properties CanUserAddRows to true to allow user to add rows. DataGrid is editable by default, where each column has an edit control which lets you edit its value. By default the DataGrid automatically generates columns for every property in your Model, so you don't even have to define it's columns.

What is the difference between grid and DataGrid in WPF?

A Grid is a control for laying out other controls on the form (or page). A DataGrid is a control for displaying tabular data as read from a database for example.

What is DataGrid in WPF?

The WPF Data Grid (GridControl) is a data-aware control designed to display and edit data in different layouts: tabular, treelike, and card. The GridControl allows users to manage large amounts of data (sort, group, filter, and so on).


1 Answers

DataGrid controls has all that functionality built-in. You can set the properties CanUserAddRows to true to allow user to add rows.

DataGrid is editable by default, where each column has an edit control which lets you edit its value. By default the DataGrid automatically generates columns for every property in your Model, so you don't even have to define it's columns.

Here are some good links with detailed examples you can look into:

http://wpftutorial.net/DataGrid.html

http://www.codeproject.com/Articles/30905/WPF-DataGrid-Practical-Examples

http://www.c-sharpcorner.com/UploadFile/mahesh/datagrid-in-wpf/

Good luck

like image 124
Omri Btian Avatar answered Sep 21 '22 14:09

Omri Btian