private void ProcessPrimaryButton() { void Complete(ContentDialogButtonClickEventArgs a) { if (!a.Cancel) { const ContentDialogResult result = ContentDialogResult.Primary; PrimaryButtonCommand.ExecuteIfPossible(PrimaryButtonCommandParameter); Hide(result); } else { _hiding = false; } } if (_hiding) { return; } _hiding = true; var args = new ContentDialogButtonClickEventArgs(Complete); PrimaryButtonClick?.Invoke(this, args); if (args.Deferral == null) { Complete(args); } }
private void PrimaryButton_Click(object sender, RoutedEventArgs e) { PrimaryButtonCommand?.Execute(PrimaryButtonCommandParameter); PrimaryButtonClick?.DynamicInvoke(); Result = CustomContentDialogResult.Primary; Hide(); }
private void ProcessPrimaryButton() { void Complete(ContentDialogButtonClickEventArgs a) { if (!a.Cancel) { const ContentDialogResult result = ContentDialogResult.Primary; PrimaryButtonCommand.ExecuteIfPossible(PrimaryButtonCommandParameter); if (Hide(result)) { _tcs.SetResult(result); } } } var args = new ContentDialogButtonClickEventArgs(Complete); PrimaryButtonClick?.Invoke(this, args); if (args.Deferral == null) { Complete(args); } }
private void OnPrimaryButtonRoutedExecuted(object sender, ExecutedRoutedEventArgs e) { LightContentDialogButtonClickEventArgs lightContentDialogButtonClickEventArgs = new LightContentDialogButtonClickEventArgs(); PrimaryButtonClick?.Invoke(this, lightContentDialogButtonClickEventArgs); if (!lightContentDialogButtonClickEventArgs.Cancel) { PrimaryButtonCommand?.Execute(PrimaryButtonCommandParameter); tcs.TrySetResult(LightContentDialogResult.Primary); } }
private void NameTextBox_KeyUp(object sender, KeyRoutedEventArgs e) { // Trigger the primary action if (e.Key == Windows.System.VirtualKey.Enter && PrimaryButtonCommand.CanExecute(null)) { // Yes, it can execute, call it PrimaryButtonCommand.Execute(null); // Close the dialog Hide(ContentDialogResult.Primary); } }