我正在使用其 ControlTemplate 中的 VirtualizingStackPanel 使用 ItemsControl。在某种程度上,我已经让虚拟化工作了。我已将调试语句放在我的 DataTemplate 中的控件的 Loaded 和 Unloaded 事件处理程序中,但在控件消失后它们不会立即卸载。有没有办法强迫这种行为?
问问题
1123 次
1 回答
2
将 VirtualizationMode 设置为 Recycled 可能会有一些运气。VirtualizingStackPanel.cs 的源代码中有注释表明 Recycled 模式会立即清理渲染器(而不是在后台执行):
//
// Delayed Cleanup is used when the VirtualizationMode is standard (not recycling) and the panel is scrolling and item-based
// It chooses to defer virtualizing items until there are enough available. It then cleans them using a background priority dispatcher
// work item
//
请注意,您可以在此处找到 VirtualizingStackPanel 的完整源代码:
于 2011-01-26T02:30:01.037 回答