ListBox和ListView有什么区别
WPF的ListBox和ListView有什么区别?我找不到它们的属性有任何显着差异。有不同的典型用途吗?
What is the difference between WPF's ListBox and ListView? I can not find any significant difference in their properties. Is there different typical use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ListView
基本上类似于ListBox
(并继承自它),但它还具有View
属性。此属性允许您指定显示项目的预定义方式。 BCL (基类库) 中唯一的预定义视图是GridView
,但您可以轻松地创建自己的。另一个区别是默认选择模式:
ListBox
的选择模式为Single
,而ListView
的选择模式为Extended
A
ListView
is basically like aListBox
(and inherits from it), but it also has aView
property. This property allows you to specify a predefined way of displaying the items. The only predefined view in the BCL (Base Class Library) isGridView
, but you can easily create your own.Another difference is the default selection mode: it's
Single
for aListBox
, butExtended
for aListView
ListView
让您可以为其定义一组视图
,并为您提供本机方式(WPF
绑定
支持)通过使用定义的视图
来控制ListView
的显示。示例:
XAML
隐藏代码:
输出:
普通视图:上面的视图 2
XAML
< /em>鼠标悬停视图:查看上面
XAML
中的 1A
ListView
let you define a set ofviews
for it and gives you a native way (WPF
binding
support) to control the display ofListView
by using definedviews
.Example:
XAML
Code Behind:
OUTPUT:
Normal View: View 2 in above
XAML
MouseOver View: View 1 in above
XAML
Listview 派生自列表框控件。
一个最重要的区别是列表视图默认使用扩展选择模式。 listview 还添加了一个名为 view 的属性,它使您能够以比自定义 itempanel 更丰富的方式自定义视图。
列表视图与网格视图的现实生活示例之一是文件资源管理器的详细信息视图。
带有网格视图的列表视图是一个不太强大的数据网格。
引入datagrid控件后listview就失去了它的重要性。
Listview derives from listbox control.
One most important difference is listview uses the extended selection mode by default . listview also adds a property called view which enables you to customize the view in a richer way than a custom itemspanel.
One real life example of listview with gridview is file explorer's details view.
Listview with grid view is a less powerful data grid.
After the introduction of datagrid control listview lost its importance.