示例#1
0
 private void PrimaryButton_Click(object sender, RoutedEventArgs e)
 {
     PrimaryButtonCommand?.Execute(PrimaryButtonCommandParameter);
     PrimaryButtonClick?.DynamicInvoke();
     Result = CustomContentDialogResult.Primary;
     Hide();
 }
示例#2
0
        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);
            }
        }