简体   繁体   English

xamarin.forms.shell 框架中页面上视觉元素的生命周期

[英]Lifetime of visual elements on a page in a xamarin.forms.shell framework

What happens to the visual elements on a contentpage, in a shell-application, when you navigate to another page?当您导航到另一个页面时,在 shell 应用程序中,内容页面上的视觉元素会发生什么变化?

The specific pages, seem to remain alive, judging by the constructors only being called on first display and not when subsequently navigating back to the page again, but it seems that some/all the visual elements on a contentpage are refreshed when navigating back to the page.特定页面似乎保持活动状态,仅在第一次显示时调用构造函数,而不是在随后再次导航回页面时,但似乎内容页面上的部分/所有视觉元素在导航回时被刷新页。

This is specifically something I see when placing a forms.map or syncfusion.sfmap on a page, and navigating away from the page and then back.这是我在页面上放置 forms.map 或 syncfusion.sfmap 并离开页面然后返回时看到的具体情况。 The maps obviously reset to initial values, on reload, so they are apparently killed off and recreated.这些地图显然会在重新加载时重置为初始值,因此它们显然被杀死并重新创建。 Making a custom renderer for a map shows OnElementChanged being called on reloading, also indicating that it was not "just kept on hand" for when the page would reload.为 map 制作自定义渲染器显示 OnElementChanged 在重新加载时被调用,这也表明它不是“随时待命”以等待页面重新加载。

It seems that the forms classes, encapsulating the deeper controls, do persist, but they disconnect from the lower level controls, and reloads them when becoming visible again?似乎 forms 类封装了更深层次的控件,确实存在,但它们与较低级别的控件断开连接,并在再次可见时重新加载它们? I am somewhat new to mobile development, and may or may not miss the entire point here...我对移动开发有点陌生,可能会也可能不会错过这里的全部要点......

The real question is if I can avoid that behavior.真正的问题是我是否可以避免这种行为。 I have a shell app with various pages containing maps.我有一个 shell 应用程序,其中包含包含地图的各种页面。 Those maps are populated with various graphics objects and are being panned and zoomed, so it is a real pain to have them reset when briefly moving away from a page.这些地图填充了各种图形对象,并且正在平移和缩放,因此在短暂离开页面时将它们重置是一件非常痛苦的事情。 Is there a way to avoid that, so they just quickly pop back to life when the page is displayed again?有没有办法避免这种情况,所以当页面再次显示时它们会迅速恢复活力?

We have analyzed the query and we would like to inform that not only Maps controls, simple ContentPage also act like this.我们已经分析了查询,我们想通知不仅 Maps 控件,简单的 ContentPage 也这样做。 It destructs the old pages and re-creates the pages view while come back in navigation.它会破坏旧页面并在导航返回时重新创建页面视图。

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

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