WPF 工具包中的 WPF DataGrid 与 ListView - 有什么好处?
我非常了解 ListView
,但从未看过 DataGrid
。
我的问题很简单 - 如果您不需要在列表中进行编辑,与 ListView
相比,DataGrid
是否提供任何优势? 另外,使用 DataGrid 是否有缺点(更复杂、性能、错误、难以设计样式等)?
I know ListView
pretty well, but never looked at DataGrid
.
My question is simple - if you do not need editing in the list, does DataGrid
provide any benefits comparing to ListView
?
Also, are there disadvantages of using DataGrid
(more complex, performance, bugs, hard to style, etc...)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
ListView 是一个只读控件。 通常的用法是将列表与由文本框组成的“详细信息视图”同步。
DataGrid 并不缺少 ListView 所拥有的任何东西,例如多重选择模式、样式等。但是,它确实提供了对 ListView 之上的某些功能的支持:
数据就地编辑
事务性编辑
自动列生成
RowDetails 设置
基本上问题是 -你想要就地编辑吗? 如果是这样,DataGrid 是一个显而易见的选择。 如果不是的话,两者非常相似。
ListView is a read-only control. The usual usage is to synchronize the list with a 'details view' comprised of TextBoxes.
The DataGrid does not lack anything that the ListView possesses, such as multiple selection modes, styling, etc. It does, however, provide support for some features on top of the ListView:
In-place editing of data
Transactional edits
Auto-column generation
Setting of RowDetails
Basically the question is - do you want in-place editing? If so, the DataGrid is an obvious choice. If not, the two are quite similar.
DataGrid 允许用户通过单击列标题对项目进行排序。
DataGrid lets user sort the items by clicking on column headers.
DataGrid 的另外两个优点:
Two more advantages of the DataGrid: