private void SaveUserCommand(object o) { // 异步请求,防止界面假死 //await Task.Run(() => //{ Application.Current.Dispatcher.Invoke(new Action(() => { ModifyUserInfoModel modifyUserInfoModel = new ModifyUserInfoModel() { user_name = UserName }; var reqResult = WebProxy(modifyUserInfoModel, ApiType.ModifyUserInfo, GlobalUser.USER.AccessToken); if (reqResult?.retCode == 0) { UserNameStatus = Visibility.Visible; EditModeStatus = Visibility.Hidden; SaveButtonStatus = Visibility.Hidden; } else { UserNameStatus = Visibility.Hidden; EditModeStatus = Visibility.Visible; SaveButtonStatus = Visibility.Visible; } })); //let's set up a little MVVM, cos that's what the cool kids are doing: var view = new SampleProgressDialog(); //show the dialog DialogHost.Show(view, o, ExtendedOpenedEventHandler, ExtendedClosingEventHandler); }
private void ExtendedClosingEventHandler(object sender, DialogClosingEventArgs eventArgs) { if (eventArgs.Parameter is bool parameter && parameter == false) { return; } //OK, lets cancel the close... eventArgs.Cancel(); var progressViewModel = new SampleProgressDialogViewModel(); var progressView = new SampleProgressDialog() { DataContext = progressViewModel }; //...now, lets update the "session" with some new content! eventArgs.Session.UpdateContent(progressView); //note, you can also grab the session when the dialog opens via the DialogOpenedEventHandler //lets run a fake operation for 3 seconds then close this baby. progressViewModel.Execute(); Task.Delay(0) .ContinueWith((t, _) => eventArgs.Session.Close(false), null, TaskScheduler.FromCurrentSynchronizationContext()); }
private async void ExecuteDeleteDialog() { var view = new SampleProgressDialog { DataContext = new SampleProgressDialogViewModel(Settings.Instance.ImageUidRegularSync, Settings.Instance.LocalisationHelper["DMLRes.Delete"], $"{SelectedItems?.Count} {GetCaptionRecords(SelectedItems.Count)}" ) }; var result = await DialogHost.Show(view, IdentifierDialogHost, ClosingDeleteEventHandler); }
public async void Loding() { try { var sampleMessageDialog = new SampleProgressDialog(); await DialogHost.Show(sampleMessageDialog, "ReadDialog"); } catch (Exception ex) { Logger.Default.Error(ex.Message); } }
public async void LogindTips() { var sampleMessageDialog = new SampleProgressDialog(); await DialogHost.Show(sampleMessageDialog, "LoginDialog"); }
public async void Loding() { var sampleMessageDialog = new SampleProgressDialog(); await DialogHost.Show(sampleMessageDialog, "ReadDialog_new"); }