/// <summary> /// 点击登录按钮,根据登录状态执行不同操作。 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void LoginButton_Click(object sender, RoutedEventArgs e) { if (LoginButton.Label == "登录") { await UpdataUserStatusAsync(); } else if (LoginButton.Label == "注销") { string choice = ""; var msgDialog = new Windows.UI.Popups.MessageDialog("确定要退出登录吗?") { Title = "注销" }; msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("确定", uiCommand => { choice = uiCommand.Label; })); msgDialog.Commands.Add(new Windows.UI.Popups.UICommand("取消", uiCommand => { choice = uiCommand.Label; })); await msgDialog.ShowAsync(); if (choice == "确定") { OAuthHelper.DeleteTokens(); await UpdataUserStatusAsync(); } } }