WPF:显示大量自定义控件
我即将开发一个 wpf 应用程序,它将用作规划工具。主要思想是显示一个表格,行是人,列是天。每个单元格分为两个较小的单元格,每个较小的单元格对应于当天(列)分配给员工(行)的任务。
应如下所示:
///////////// 第 1 天//第 2 天//第 3 天//第 4 天//第 5 天//第 6 天//第 7 天
People1 E1/E2 E1/ E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2
人员2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2
People3 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2
我需要能够使用自定义控件作为一个较小的单元格(一个“任务”)。
我尝试操作 ItemsControl、DataGrid,但每次它都会显示性能问题:要么滚动(水平和垂直)滞后,要么应用程序绘制组件所用的时间太重要。
由于我似乎需要新的想法来解决性能问题,我想知道是否其他人也遇到过同样的问题,并设法解决它..
有什么建议吗?
I'm about to develop a wpf app which will be used as a planning tool. The main idea is to display a table, rows are people, columns are days. Each cell is split into two smaller cells, each smaller cell corresponds to a task assigned to the employee (the row) for the day (the column).
Should look like this :
///////////// Day 1//Day 2//Day 3//Day 4//Day 5//Day 6//Day 7
People1 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2
People2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2
People3 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2 E1/E2
I need to be able to use a customcontrol as one smaller cell (one "task").
I tried to manipulate ItemsControl, DataGrid, but everytime it was showing performance issues : either the scrolling (both horizontally and vertically) was laggy, or the time used by the app to draw the components was way too important.
As I seem to need new ideas to solve the performance issue, I was wondering if maybe someone else have had the same problem, and managed to deal with it..
Any suggestion?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
ItemsControl
已知存在性能问题。您可以尝试切换到ListBox
或ListView
,因为它们基于VirtualizingStackPanel
。此外,问题 WPF - 虚拟化 ItemsControl? 包含有关虚拟化
ItemsControl 的更多信息
。此外,在最近的 Build 会议上宣布 .NET 4.5将包含对
ItemsControl
的显着性能改进。 Ira Lukhezo 在题为 .NET 4.5 中的 ItemsControl 性能改进。ItemsControl
is known to have performance problems. You can try to switch toListBox
orListView
because they are based on aVirtualizingStackPanel
.Also, the question WPF - Virtualizing an ItemsControl? has more information about virtualizing an
ItemsControl
.Furthermore, it was announced at the recent Build conference that .NET 4.5 will contain considerable performance improvements to
ItemsControl
. Ira Lukhezo sums it up in a blog entry titled ItemsControl Performance Improvements in .NET 4.5.好的,如果您使用的是
DataGrid
,请检查ListView
是否提供更好的结果。或者
我希望您将 DataGrid 与 DataGridTemplateColumns 一起使用,如果是这样,则在
CellEditingTemplate
中显示功能图形 E1/E2,并在Celltemplate< 中显示 E1/E2 的快照
绘图
/代码>。它们看起来都一样,但基于绘图的效果会更好,因为绘图在渲染时是Freezable
。OK if you are using
DataGrid
then check ifListView
gives better results.OR
I hope you are using DataGrid with DataGridTemplateColumns, if so then show the Functional Graphical E1/E2 in
CellEditingTemplate
and a snapshotDrawing
of E1/E2 inCelltemplate
. They both will look the same but Drawing based one will perform better as the Drawing isFreezable
while rendering.