Xamarin形式:等效于.Finish() [英] Xamarin forms: The equivalent of .Finish()
问题描述
我有一个Xamarin Forms应用程序,在所有三个平台上都很好.该应用程序具有一个登录屏幕和一个用户已成功登录的其他页面.有没有办法与Xamrin for Android提供的Finish方法等效,该方法可以从导航堆栈中删除登录页面?如果用户持续按下后退"按钮,则他们最终将返回登录屏幕,这是不希望的.我曾尝试使用Navigation.PopAsync(),但似乎无法正常工作
I have a Xamarin Forms application which very well on all three platforms. The app has a login screen and other pages that are available one a user has successfully logged in. My question is: In Xamarin Forms; is there a way to have the equivalent of the Finish method that Xamrin for Android provides to remove the login page from the navigation stack? If a user keeps pressing the back button they eventually get back to the login screen which is undesirable. I have tried using Navigation.PopAsync () but seem not to work
推荐答案
Navigation.PopAsync
和Navigation.RemovePage
应该可以工作.
但是,如果您的页面也是MainPage
,则无法将其删除.您可以使用以下代码将其更改为另一个页面:
BUT if your page is also a MainPage
you can't remove it. You could change it to another page using this code:
App.Current.MainPage = new NavigationPage(new MyContentPage());
这篇关于Xamarin形式:等效于.Finish()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!