Windows 10 UWP - 如何在显示之前预加载页面?
Windows 10 UWP - How to preload a page before displaying it?
我正在开发一个涉及使用大量图像的 Windows 10 应用程序。就目前而言,从一个页面导航到另一个页面需要几秒钟的时间 "pop-in",因为页面上的各种图像会加载,结果相当卡顿
所以 TL;DR - 是否可以在向用户显示页面之前预加载页面内容,以便从页面 x 到页面 y 的过渡顺利?
我已经尝试使用谷歌搜索解决方案,但我不知道是我使用的白话错误还是无法完成,我不知道。
你的朋友是 Loaded
事件,将在视图中加载 UIElement
后触发..
你可以这样做:默认情况下,图像列表是Opacity
= 0,并设置加载事件:图像列表Opacity
= 1..
这样,您可以确保列表在加载之前是不可见的:)
Is it possible to preload the contents of a page before displaying it to the user so that the transition from page x to page y is smooth?
在 UWP 应用程序中,在加载页面之前,必须调用 Frame.Navigate()。该方法中应该有一些操作,例如:分配内存、加载资源、渲染。所以对于你的场景,在我看来,在显示它们之前预加载页面的资源是不可能的。
避免使用尺寸过大的图像是一种可能的解决方案。或者,如果你只想加载很多小图片,
You can bind list controls to arbitrarily large data sources, and still achieve high performance, by using incremental loading.
当您需要在一个页面中加载大量图片时,正确的做法是使用 ISupportIncrementalLoading with Data binding. You can refer to Data binding in depth.
这里是官方XAML data binding sample,场景8是关于增量加载的。虽然这是一个 windows 8.1 应用程序,但此方法也可以在 UWP 应用程序中使用。
我在这里写了一个简单的IncrementalLoading演示,它只是使用其中的GridView
和Image
来加载并在一页中显示1000张图片。
我正在开发一个涉及使用大量图像的 Windows 10 应用程序。就目前而言,从一个页面导航到另一个页面需要几秒钟的时间 "pop-in",因为页面上的各种图像会加载,结果相当卡顿
所以 TL;DR - 是否可以在向用户显示页面之前预加载页面内容,以便从页面 x 到页面 y 的过渡顺利?
我已经尝试使用谷歌搜索解决方案,但我不知道是我使用的白话错误还是无法完成,我不知道。
你的朋友是 Loaded
事件,将在视图中加载 UIElement
后触发..
你可以这样做:默认情况下,图像列表是Opacity
= 0,并设置加载事件:图像列表Opacity
= 1..
这样,您可以确保列表在加载之前是不可见的:)
Is it possible to preload the contents of a page before displaying it to the user so that the transition from page x to page y is smooth?
在 UWP 应用程序中,在加载页面之前,必须调用 Frame.Navigate()。该方法中应该有一些操作,例如:分配内存、加载资源、渲染。所以对于你的场景,在我看来,在显示它们之前预加载页面的资源是不可能的。
避免使用尺寸过大的图像是一种可能的解决方案。或者,如果你只想加载很多小图片,
You can bind list controls to arbitrarily large data sources, and still achieve high performance, by using incremental loading.
当您需要在一个页面中加载大量图片时,正确的做法是使用 ISupportIncrementalLoading with Data binding. You can refer to Data binding in depth.
这里是官方XAML data binding sample,场景8是关于增量加载的。虽然这是一个 windows 8.1 应用程序,但此方法也可以在 UWP 应用程序中使用。
我在这里写了一个简单的IncrementalLoading演示,它只是使用其中的GridView
和Image
来加载并在一页中显示1000张图片。