ListBox与ListView - 如何选择数据绑定 [英] ListBox vs. ListView - how to choose for data binding

查看:298
本文介绍了ListBox与ListView - 如何选择数据绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑一个WPF应用程序的ListBox或ListView。它似乎支持数据绑定和项目模板。我的应用程序有一个简单的项目列表,我打算根据用户输入进行搜索/排序/过滤。数据绑定演示( http://msdn.microsoft.com/en-us/ library / ms771319.aspx )使用ListBox与CollectionViewSource。



有谁拥有使用哪个控件的优缺点?

解决方案>

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆