Exemplo n.º 1
0
 private static void Window_Closing(object sender, CancelEventArgs e)
 {
     var command = GetClosingCommand((DependencyObject)sender);
     if (command != null &&
         command.CanExecute(null))
     {
         var args = new WindowClosingArgs();
         command.Execute(args);
         e.Cancel = args.Cancel;
     }
 }
Exemplo n.º 2
0
 private static void DialogResultButton_Click(object sender, RoutedEventArgs e)
 {
     var button = sender as Button;
     var window = VisualTreeAssist.FindParent<Window>(button);
     if (window != null)
     {
         var resultCommand = WindowBehavior.GetDialogResultCommand(button);
         if (resultCommand != null)
         {
             var args = new WindowClosingArgs();
             resultCommand.Execute(args);
             if (!args.Cancel)
                 window.DialogResult = args.DialogResult;
         }
         else
             window.DialogResult = WindowBehavior.GetDialogResult(button);
     }
 }