WPF DataGrid control is used for display and edit tabular data in rows and columns. DataGrid control is introduced in .NET 4.0.
DataGrid control main features are:
- Bind to any collection that implements IEnumerable interface
- Auto generate data rows and columns based on bounded data.
- Provides different row selection-modes: Single/Extended
- Provides options for grouping, sorting, filtering columns
- Validation support
- UI Virtualization support for both rows and columns
- Frozen Columns
- RowDetails template for showing extra content of row
- Editing support for editing rows and columns
WPF DataGrid looks like WPF ListView Control as both display data in tabular format. But there are some major differences.
Difference between WPF DataGrid and WPF ListView
There are four main differences between both.
- Editing support
- Auto Generate Columns
- Row Details
- Frozen Columns
Editing support
WPF DataGrid provides inbuilt support for directly editing data. But ListView shows only read-only view of data.
Auto Generate Columns
WPF DataGrid automatically generate columns for display from the data source you have bind through ItemsSource property. But in ListView, you have to manually define the columns to display.
Row Details
WPF DataGrid provides you an option for display additional details of row which you can show/hide based on setting of RowDetailsVisibilityMode property. But WPF ListView does not provide any option for showing additional details of row.
Frozen Columns
DataGrid lets you defines some columns to be freeze so that if you move in your DataGrid, frozen columns will not move.