views:

1145

answers:

4

I know ListView pretty well, but never looked at DataGrid.

My question is simple - if you do not need editing in the list, does DataGid provide any benefits comparing to ListView? Also, are there disadvantages of using DataGrid (more complex, performance, bugs, hard to style, etc...)?

+1  A: 

DataGrid lets user sort the items by clicking on column headers.

Pavel Minaev
+3  A: 

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.

Charlie
I agree with the answer, but disagree with the conclusion. Even if you are not editing in place, DataGrid is a preferred choice because of ease of adding a sort and RowDetails view. So my advice would be - if you have golumns, start with DataGrid and you would not have to switch later.
Sergey Aldoukhov
ListView is not really read-only. You can easily make each cell in a ListView editable by using the appropriate templates.
Tarydon
+1  A: 

What about performance? Is there any difference?

Andreas
Same performance
Sergey Aldoukhov
A: 

Two more advantages of the DataGrid:

  1. Fixed Columns and Column Headers.
  2. Headers are styled more easily than in ListView.
Sergey Aldoukhov