[英]Xamarin.forms - Redirect to anther page without navigation
我正在使用 Xamarin.forms,我有一個 MainPage,它是我的登錄頁面,有人登錄后我想將它們重定向到我的主頁,但是當我使用時:
await Application.Current.MainPage.Navigation.PushAsync(new HomePage());
頂部有一個導航,如果沒有導航,我將如何做到這一點,完整的方法:
public async void OnSubmit(object sender, EventArgs args)
{
UsersClass usersClass = api.loginUser(Username.Text, Password.Text);
if (usersClass.response != null)
{
await DisplayAlert("Error", usersClass.response, "OK");
}
else
{
Application.Current.Properties["username"] = Username.Text;
Application.Current.Properties["isLogin"] = true;
await Application.Current.SavePropertiesAsync();
await Application.Current.MainPage.Navigation.PushAsync(new MenuPage(), true);
}
}
只需重新分配MainPage
Application.Current.MainPage = new MenuPage();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.