UWP 框架导航。是否可以在后台加载视图?

UWP Frame Navigation. Is it possible to load a view in background?

我有类似幻灯片的东西这里是代码:

private int index;
        private List<Type> pages = new List<Type>() { typeof(ChartWheaterPage), typeof(ChartServerPage), typeof(mitarbeiteronlinePage), typeof(MomentaneKundenPage), typeof(OutlookKalenderPage), typeof(fdösjf), typeof(ChartZielPage) };
        public MainPage()
        {

            this.InitializeComponent();
            var timer = new DispatcherTimer();
            timer.Interval = TimeSpan.FromSeconds(20);
            timer.Tick += Timer_Tick;
            timer.Start();

        }


            private void Timer_Tick(object sender, object e)
            {
                grid_loading.Opacity = 0;
                if (index == pages.Count)
                {
                    index = 0;
                }
                this.contentFrame.Navigate(pages[index]);
                index++;
            }

    }

但问题是我使用 Grafana,当我加载视图 ChartWheaterPage 时,Grafana 加载 20-30 秒。有没有办法在启动时加载页面并显示它只加载一次

Is there a way to load the page on startup and show it that it only loads one time?

先解决后一个问题,让页面只初始化一次

默认情况下,应用程序会在您每次导航时创建一个新页面,如果您想重复使用该页面,您可以缓存该页面,以便下次导航时首先使用缓存的页面。

public MyPage()
{
    this.InitializeComponent();
    NavigationCacheMode = NavigationCacheMode.Enabled;
}

在此基础上,如果你的某个页面需要加载很长时间,而且不是幻灯片的第一页,可以考虑在应用启动时跳转到该页面,然后再跳转到初始页面.

由于您跳转到该页面并启用了缓存,该页面将继续加载。 20-30秒后进入页面时,页面已经加载完毕,可以显示了。

谢谢。