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?
A
ListViewis a specializedListBox(that is, it inherits fromListBox). It allows you to specify different views rather than a straight list. You can either roll your own view, or useGridView(think Explorer-like "details view"). It’s basically the multi-columnListBox, the cousin of Windows Forms’ListView.If you don’t need the additional capabilities of
ListView, you can certainly useListBoxif you’re simply showing a list of items (Even if the template is complex).