private void CloseButton_Click(object sender, RoutedEventArgs e) { if (dialog.Cancel != null) { dialog.Cancel(); } else { dialog.Close(); } }