public async Task<object> Execute( MetroWindow window, object args ) { Window = window; Csa = args as ConfirmationServiceArgs; Debug.Assert( Csa != null, "Csa != null" ); Dialog = new ConfirmDialog(); Tcs = new TaskCompletionSource<bool?>(); Vm = Dialog.DataContext as ConfirmDialogViewModel; Debug.Assert( Vm != null, "Vm != null" ); Vm.Reset(); Vm.AffirmativeText = Csa.AffirmativeText; Vm.NegativeText = Csa.NegativeText; Vm.Title = Csa.Title; Vm.Message = Csa.Message; Vm.DisplayDontAskAgain = Csa.DisplayDontAskAgain; Vm.CloseRequested += Vm_CloseRequested; await window.ShowMetroDialogAsync( Dialog ); return await Tcs.Task; }
public async Task<object> Execute( MetroWindow window, object args ) { var pathDlg = new DatabasePathDialog(); var vm = pathDlg.DataContext as DatabasePathViewModel; Debug.Assert( vm != null ); TaskCompletionSource<MoveDatabaseResult> tcs = new TaskCompletionSource<MoveDatabaseResult>(); vm.CloseRequested += async ( s, e ) => { await window.HideMetroDialogAsync( pathDlg ); tcs.TrySetResult( new MoveDatabaseResult( vm.Path, vm.OverwriteExisting ) ); }; await window.ShowMetroDialogAsync( pathDlg ); return await tcs.Task; }
public async Task<object> Execute( MetroWindow window, object args ) { var settings = new MetroDialogSettings(); var dlg = new InfoDialog(); var ctrl = dlg.DataContext as IViewController; if( ctrl != null ) { ctrl.CloseRequested += async ( s, e ) => { await window.HideMetroDialogAsync( dlg, settings ); }; } await window.ShowMetroDialogAsync( dlg, settings ); return null; }