WPF DataGrid from WPF toolkit vs ListView - any benefits?
-
19-09-2019 - |
Question
I know ListView
pretty well, but never looked at DataGrid
.
My question is simple - if you do not need editing in the list, does DataGrid
provide any benefits comparing to ListView
?
Also, are there disadvantages of using DataGrid
(more complex, performance, bugs, hard to style, etc...)?
Solution
ListView is a read-only control. The usual usage is to synchronize the list with a 'details view' comprised of TextBoxes.
The DataGrid does not lack anything that the ListView possesses, such as multiple selection modes, styling, etc. It does, however, provide support for some features on top of the ListView:
In-place editing of data
Transactional edits
Auto-column generation
Setting of RowDetails
Basically the question is - do you want in-place editing? If so, the DataGrid is an obvious choice. If not, the two are quite similar.
OTHER TIPS
DataGrid lets user sort the items by clicking on column headers.
Two more advantages of the DataGrid:
- Fixed Columns and Column Headers.
- Headers are styled more easily than in ListView.