编写一个同时具有列和行虚拟化的网格
我需要编写一个像Excel一样的网格,该网格可以具有很多单元(400x400)。所有列的宽度相同,所有行都具有相同的高度。每个单元格可以包含文本或空为空,并且每个单元格可以具有列和/或行跨度。我想这永远不会与
因此,我的第一次尝试是通过源自“ nofollow”>“ nofollow”> virtualizingpanel 并实现。除了我遇到一个问题之外,这可能是“很容易”的解决方案:
为isCrollinfo
提供有关滚动尺寸和位置的相关信息,并能够创建确定项目(已实现) )接下来,使用item -scontainerengenerator,我需要知道每个子项目(单元格)的列索引,行和列型。我能想到的唯一方法是使用附加属性。问题是:我只能读取具有它们的itemContainer的值。所以我在这里22。要知道什么可以意识到我需要意识到所有项目。要提供isCrollinfo
的数据,我需要实现所有项目。
因此,看来我对这种方法处于终结状态。
您是否知道如何实现这样的控制或知道如何重新解决上述问题?
I need to write an excel-like grid that can have a lot of cells (400x400). All columns have the same width and all rows the same height. Each cell can contain text or be empty and each cell can have a column and/or row span. I suppose this will never work with the Grid panel and I suppose I will need UI virtualization in both column and row direction.
So my first try was to create a virtualizing grid by deriving from VirtualizingPanel and implement IScrollInfo. This could have "easily" be the solution except that I ran into a problem:
To provide IScrollInfo
with the relevant information about scroll size and position and to be able to detemine wich items need to be created (realized) next using the ItemsContainerGenerator, I need to know the column index, row indeox and columnspan for each child item (cell). The only way I can think of to do this is using attach properties. The problem is: I can only read the values of attached properties if the ItemContainer that has them is already realized. So I am in a catch 22 here. To know what to realize I need to realize all items. To provide the data for IScrollInfo
I need to realize all items.
So it seems that I am at a dead end with this approach.
Do you have any idea how I could implement a control like this or know how I could reslove the above problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让我印象深刻的是,您可能不需要实例化 UI 元素本身 - 您可以非常轻松地拥有 DependencyObject 派生视图模型的集合,每个视图模型都具有 WidthProperty 和 HeightProperty 集(并且可能绑定到可见的单元格 UI 元素(一旦创建)。
存储 160,000 (400x400) 个类实例应该不是问题,特别是如果您能够使用行和列对集合进行索引。
It strikes me that you may not need to instanciate the UI elements themselves- you can very easily have a collection of DependencyObject-derived viewmodels, each of which has the WidthProperty and HeightProperty set (and possibly bound to the equivalent Width and Height properties of the visible cell UI element, once those are created).
Storing 160,000 (400x400) class instances shouldn't be a problem, especially if you are able to index into the set using row and column.