What is the difference between ListView and GridView in WPF?

advertisements

I am trying to create a WPF database application. There seems to be a few good components that I can use for showing the data in the database tables. ListView and GridView seems to be popular for this usage. But for a novice, it's hard to see the difference between them.

What is the difference between ListView and GridView? What are the pros and cons?


A ListView is a WPF control, deriving from ListBox, that (in theory) can render the items using one of several view modes which are derived from ViewBase. GridView is the only one implemented. So in other words, it's not a choice of ListView or GridView. If you want to display tabular data in a ListView, you would create a ListView and set its View to a GridView (which defines the column layout.)

The reality, however, is that as far as I know, no other views were implemented. And because ListView is not a very feature-rich control, it's largely obsolete at this point. In fact, Silverlight does not even provide ListView.

There is a DataGrid control that is very close in functionality and API to the Silverlight DataGrid control and you should probably use this instead of a ListView.