[英]How to resume the app with another page then the suspended?
I need to ask for a passcode every time the app was suspended (and resumed), so I have to show a corresponding page, and after the user enters the pin proceed the app resuming to the page which was shown before suspending. 每次暂停(恢复)应用程序时,我都需要输入密码,因此我必须显示相应的页面,并且在用户输入图钉之后,继续将应用程序恢复到暂停之前显示的页面。 How can I get the page to which I have to proceed?
如何获得必须进入的页面? The App.Resume event provides 2 parameters, but both of them are objects.
App.Resume事件提供2个参数,但它们都是对象。 To which type I need to cast these objects to get the proper page's type?
我需要将这些对象转换为哪种类型以获得正确的页面类型? Can I get from these parameters the proper page type at all?
我能否从这些参数中获得正确的页面类型?
I mean 我的意思是
private void OnResuming(object sender, object e)
{
//get the suspended page's type here
}
Thanks :) 谢谢 :)
I recommend the following: In OnResuming simply Navigate to the passcode page, but remember the current page before. 我建议以下内容:在OnResuming中,只需导航至密码页面,但请记住之前的当前页面。 OnResuming should look like this:
OnResuming应该看起来像这样:
//...
// the following line returns something like e.g. "MainPage"
var pageTypeName = ((Frame)Window.Current.Content).SourcePageType.Name;
// store pageTypeName in app scope
// Navigate to passcode page ...
When passcode was entered correctly navigate to the previous page. 正确输入密码后,导航至上一页。
Second Option: You can also try to navigate to the passcode page during "OnSuspending". 第二种选择:您也可以尝试在“ OnSuspending”期间导航到密码页面。 The user will see the passcode page after a resume.
恢复后,用户将看到密码页面。 After entering the code you can redirect the user to the previous page.
输入代码后,您可以将用户重定向到上一页。 Of course you also have to store the type of the current page during OnSuspending accordingly.
当然,您还必须在OnSuspending期间存储当前页面的类型。
The code shown works fine if you have an "easy" interface without eg a SplitView. 如果您具有“简易”界面而不使用例如SplitView,则显示的代码可以正常工作。 You probably have to tweak it a little if you are working with nested Frames etc.
如果您使用嵌套框架等,则可能需要稍微调整一下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.