UI HubSection中GridView和ListView的虚拟化

UI Virtualization of GridView and ListView in HubSection

我刚刚注意到,如果我将 UWP 应用程序中的 GridView 或 ListView 放在 HubSection 内,UI 虚拟化就会中断。我的理解正确吗?

谢谢

虚拟化只发生在视口外的项目上。因此,将您的 GridView 放入限制其大小的控件(例如 Grid 没有自动调整大小 rows/columns)或设置控件的大小非常重要。如果您的 HubSection 没有固定大小,我不会感到惊讶。

The concept of a viewport is critical to UI virtualization because the framework must create the elements that are likely to be shown. In general, the viewport of an ItemsControl is the extent of the logical control. For example, the viewport of a ListView is the width and height of the ListView element. Some panels allow child elements unlimited space, examples being ScrollViewer and a Grid, with auto-sized rows or columns. When a virtualized ItemsControl is placed in a panel like that, it takes enough room to display all of its items, which defeats virtualization. Restore virtualization by setting a width and height on the ItemsControl.

自定义模板也经常破坏虚拟化:

If you provide a custom items panel template (see ItemsPanel) then make sure you use a virtualizing panel such as ItemsWrapGrid or ItemsStackPanel. If you use VariableSizedWrapGrid, WrapGrid, or StackPanel, then you will not get virtualization.

关于 MSDN 的更多信息:UWP and Win8,它也有一些仍然重要的优点。