328

I'm considering either a ListBox or a ListView for a WPF application. It seems either supports data binding and item templates. My application has a simple list of items that I intend to be able to search/sort/filter based on user input. The data binding demo (http://msdn.microsoft.com/en-us/library/ms771319.aspx) uses a ListBox with a CollectionViewSource.

Does anyone have pros/cons for which control to use and when?

H.B.
  • 166,899
  • 29
  • 327
  • 400
Geoff Cox
  • 6,102
  • 2
  • 27
  • 30

1 Answers1

376

A ListView is a specialized ListBox (that is, it inherits from ListBox). It allows you to specify different views rather than a straight list. You can either roll your own view, or use GridView (think explorer-like "details view"). It's basically the multi-column listbox, the cousin of windows form's listview.

If you don't need the additional capabilities of ListView, you can certainly use ListBox if you're simply showing a list of items (Even if the template is complex).

Philip Rieck
  • 32,368
  • 11
  • 87
  • 99
  • 4
    What's the difference between that and `DataGrid`? Unless `ListView` enables you to change the view dynamically (like win-explorer - list, details, large icons), I don't see why using it... – JobaDiniz May 27 '17 at 12:53