private void ButtonExport_Click(object sender, RoutedEventArgs e) { this.textProgressInformation.Text = "Document exportation started..."; this.progressScrollViewer.ScrollToBottom(); Microsoft.Win32.SaveFileDialog saveFileDialog = new Microsoft.Win32.SaveFileDialog(); saveFileDialog.Filter = "XPS files (*.xps)|*.xps|All files (*.*)|*.*"; bool jobCompleted = false; if (saveFileDialog.ShowDialog().GetValueOrDefault()) { Size size = new Size(8.5d * 96.0d, 11.0d * 96.0d); m_printButton.IsEnabled = false; m_exportButton.IsEnabled = false; try { jobCompleted = GridDetails.ExportToXps(saveFileDialog.FileName, size, new Rect(size), new PageRange(1, 0), CompressionOption.Normal, new EventHandler <ProgressEventArgs>(this.ProgressionCallBack), true); } catch (System.IO.IOException) { jobCompleted = false; } finally { m_printButton.IsEnabled = true; m_exportButton.IsEnabled = true; } } if (jobCompleted) { this.textProgressInformation.Text += "\n...Completed."; } else { this.textProgressInformation.Text += "\n...Canceled."; } this.progressScrollViewer.ScrollToBottom(); }