private async void Button_ClickAsync(object sender, RoutedEventArgs e) { string _pid = TB_UserName.Text; if (_pid == "") { MessageDialog md = new MessageDialog("name can't be null", "Error"); md.Commands.Add(new UICommand("ok")); await md.ShowAsync(); return; } string _pwd = TB_Password.Password; if (_pwd == "") { MessageDialog md = new MessageDialog("password can't be null", "Error"); md.Commands.Add(new UICommand("ok")); await md.ShowAsync(); return; } LoginUser _lu = LoginUser.CreateObj(_pid, _pwd); LoginUser.UserNotFoundReceipt _Receipt = LoginUser.UserNotFoundReceipt.None; if (CB_CreateNew.IsChecked == null ? false : (bool)CB_CreateNew.IsChecked) { _Receipt = LoginUser.UserNotFoundReceipt.Create; } else { _lu.UserNotFoundEvent += (obj) => { ShowMesAsync("we can't find your info"); SubmitBTN.Content = new TextBlock() { Text = "Submit" }; }; } _lu.UserPwdVertifyFailEvent += (obj) => { SubmitBTN.Content = new TextBlock() { Text = "Submit" }; ShowMesAsync("password vertify failed"); }; _lu.UserVertifyEvent += (obj) => { Frame.Navigate(typeof(Userpage)); }; SubmitBTN.Content = new LoadingCtrl(); await _lu.TryLoginAsync(_Receipt); }