VirtualizingStackPanel 如何决定何时卸载(处置?)虚拟化控件?
我正在使用 ItemsControl,在其 ControlTemplate 中使用 VirtualizingStackPanel。在某种程度上,我已经实现了虚拟化。我已将调试语句放入项目的 DataTemplate 中控件的 Loaded 和 Unloaded 事件处理程序中,但在控件退出视图后它们不会立即卸载。有什么办法可以强制这种行为吗?
I'm working with an ItemsControl using a VirtualizingStackPanel in its ControlTemplate. I've got the virtualization working, to some extent. I've put debugging statements in the Loaded and Unloaded event handlers for the controls in my DataTemplate for the items, but they don't get unloaded immediately after the controls go out of view. Is there any way to force this behaviour ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可能会幸运地将 VirtualizationMode 设置为 Recycled。 VirtualizingStackPanel.cs 源代码中的注释表明回收模式会立即清理渲染器(而不是在后台执行):
注意,您可以在此处找到 VirtualizingStackPanel 的完整源代码:
http://referencesource.microsoft.com/netframework.aspx
You might have some luck setting the VirtualizationMode to Recycled. There are comments in the source code for VirtualizingStackPanel.cs that indicate Recycled mode immediately cleans up renderers (instead of doing it in the background):
Note, you can find the full source for VirtualizingStackPanel here:
http://referencesource.microsoft.com/netframework.aspx