注销显示警报 xamarin.forms

编程入门 行业动态 更新时间:2024-10-26 16:28:37
本文介绍了注销显示警报 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

本文发布于:2023-11-27 16:56:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1638837.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:警报   xamarin   forms

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!