ListBox与ListView - 如何选择数据绑定 [英] ListBox vs. ListView - how to choose for data binding
问题描述
有谁拥有使用哪个控件的优缺点?
ListView是一个专门的ListBox(也就是继承自ListBox)。它允许您指定不同的视图,而不是直线列表。您可以滚动自己的视图,也可以使用GridView(像浏览器一样的细节视图)。它基本上是多列列表框,Windows窗体列表的表哥。
如果您不需要ListView的其他功能,您一定可以使用ListBox,只需显示一个项目列表(即使模板很复杂)。
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 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).
这篇关于ListBox与ListView - 如何选择数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!