本文介绍了注销显示警报 xamarin.forms的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在尝试允许用户使用 DisplayAlert 确认注销.如果他们点击否",它应该保留在他们的个人资料页面中,否则他们应该被重定向回登录页面.我还没有完成,如果我点击是或否,这两个选项都保留在个人资料页面中
I've been trying to allow a user to confirm logout by using DisplayAlert. If they click "No" it should remain in their profile page else they should be redirected back to the login page. I haven't managed to get this done, if I click Yes or No, both options remain in the profile page
public async void LogoutBtn(object sender, EventArgs e) { var answer = await DisplayAlert("Exit", "Do you wan't to exit the App?", "Yes", "No"); if(answer.Equals("Yes")) { Settings.FirstName = string.Empty; Settings.LastName = string.Empty; Settings.Email = string.Empty; await Navigation.PushAsync(new MainPage()); } else { App.Current.MainPage = new Profile(); } } 推荐答案DisplayAlert 返回一个布尔值 (true/false):
DisplayAlert returns a boolean (true / false):
var answer = await DisplayAlert("Exit", "Do you wan't to exit the App?", "Yes", "No"); if (answer) { // User choose Yes } else { // User choose No }更多推荐
注销显示警报 xamarin.forms
发布评论