简体   繁体   English

在应用启动时(或在导航至时)预先构建XAML?

[英]Pre-build out the XAML at app start (or On Navigated to)?

I've got a Windows Phone 8.1 app with a user preferences page. 我有一个带有用户首选项页面的Windows Phone 8.1应用。 There is a color picker on that page that is initially 'collapsed' until the user taps a part of the page. 该页面上有一个颜色选择器,该颜色选择器最初是“折叠”的,直到用户点击页面的一部分。 When they do, it takes XAML about 3 seconds to build the color picker (140 little colored text blocks all bound to a list). 当他们这样做时,XAML大约需要3秒钟来构建颜色选择器(140个几乎没有颜色的文本块都绑定到一个列表)。 The user sees a 3-second delay the first time they tap on the control. 用户第一次点击控件时会看到3秒的延迟。 Once rendered, coming back to that color picker a second time (as long as the page has remained open) is instantaneous. 渲染后,第二次回到该颜色选择器(只要页面保持打开状态)是瞬时的。

Basically, I've got a really complicated XAML page with hundreds and hundreds of Textboxes and I want to pre-build it so there's no delay when I want to display it. 基本上,我有一个非常复杂的XAML页面,其中包含数百个文本框,我想对其进行预构建,因此在显示它时没有任何延迟。

Is there a way I can tell XAML or my code-behind to pre-build the color picker so that it's ready to display if and when the user taps on the box to show it? 有没有一种方法可以告诉XAML或我的背后代码预构建颜色选择器,以便在用户点击框以显示它时可以显示它?

I have seen the answer to a similar question at: How to preload XAML at app startup? 我在以下位置看到了类似问题的答案: 如何在应用程序启动时预加载XAML? and I don't understand it, or even know if it applies to me. 我不理解它,甚至不知道它是否适用于我。

The question you are referring to have answer to your problem. 您所指的问题可以解决您的问题。 If you need to load so many items then you can use that approach. 如果您需要装载这么多物品,则可以使用该方法。 The only thing you need to keep in mind is that if user taps to make color picker visible before it's fully loaded then it will not be ready and a delay will be shown. 您唯一需要记住的是,如果用户轻按以在拾色器完全加载之前使其可见,则拾色器将无法就绪,并会显示延迟。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM