ListBox vs. ListView - 如何选择数据绑定 [英] ListBox vs. ListView - how to choose for data binding
问题描述
我正在考虑为 WPF 应用程序使用 ListBox 或 ListView.似乎支持数据绑定和项目模板.我的应用程序有一个简单的项目列表,我打算根据用户输入搜索/排序/过滤这些项目.数据绑定演示 (http://msdn.microsoft.com/en-us/library/ms771319.aspx) 使用带有 CollectionViewSource 的 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?
推荐答案
ListView 是一个专门的 ListBox(也就是说,它继承自 ListBox).它允许您指定不同的视图而不是直接列表.您可以滚动自己的视图,也可以使用 GridView(想想类似资源管理器的详细信息视图").它基本上是多列列表框,是 windows 窗体列表视图的表亲.
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.
如果您不需要 ListView 的附加功能,如果您只是显示项目列表(即使模板很复杂),您当然可以使用 ListBox.
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 vs. ListView - 如何选择数据绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!