private void Hide(ContentDialogResult result) { void Complete(ContentDialogClosingEventArgs args) { if (!args.Cancel) { _popup.IsOpen = false; Closed?.Invoke(this, new ContentDialogClosedEventArgs(result)); } } var closingArgs = new ContentDialogClosingEventArgs(Complete, result); Closing?.Invoke(this, closingArgs); if (!closingArgs.IsDeferred) { Complete(closingArgs); } else { closingArgs.EventRaiseCompleted(); } }
private bool Hide(ContentDialogResult result) { void Complete(ContentDialogClosingEventArgs args) { if (!args.Cancel) { m_isShowing = false; _popup.IsOpen = false; _popup.Child = null; UpdateVisualState(); Closed?.Invoke(this, new ContentDialogClosedEventArgs(result)); _tcs.SetResult(result); } _hiding = false; } var closingArgs = new ContentDialogClosingEventArgs(Complete, result); Closing?.Invoke(this, closingArgs); if (!closingArgs.IsDeferred) { Complete(closingArgs); } else { closingArgs.EventRaiseCompleted(); } return(!closingArgs.Cancel); }
private bool Hide(ContentDialogResult result) { void Complete(ContentDialogClosingEventArgs args) { if (!args.Cancel) { m_isShowing = false; _popup.IsOpen = false; _popup.Child = null; UpdateVisualState(); Closed?.Invoke(this, new ContentDialogClosedEventArgs(result)); // Make sure all clean-up is done before returning result, // to prevent problems when the dialog is reopened synchronously (var tcs, _tcs) = (_tcs, null); DispatcherQueue.TryEnqueue(() => tcs?.TrySetResult(result)); } _hiding = false; } var closingArgs = new ContentDialogClosingEventArgs(Complete, result); Closing?.Invoke(this, closingArgs); var completedSynchronously = closingArgs.DeferralManager.EventRaiseCompleted(); return(completedSynchronously && !closingArgs.Cancel); }