private void PrintPage_Executed(object sender, ExecutedRoutedEventArgs e) { using (PrintWindow window = new PrintWindow()) { window.EnsureButtonClick += (sender1, e1) => { PrintExecute(sender, window.IsRecursion); window.Close(); }; window.ShowDialog(); } }