ContentDialogExtensions.cs 445 B

12345678910111213141516171819202122
  1. namespace NatTypeTester.Extensions;
  2. internal static class ContentDialogExtensions
  3. {
  4. public static async ValueTask HandleExceptionWithContentDialogAsync(this Exception ex, XamlRoot root)
  5. {
  6. ContentDialog dialog = new();
  7. try
  8. {
  9. dialog.XamlRoot = root;
  10. dialog.Title = nameof(NatTypeTester);
  11. dialog.Content = ex.Message;
  12. dialog.PrimaryButtonText = @"OK";
  13. await dialog.ShowAsync();
  14. }
  15. finally
  16. {
  17. dialog.Hide();
  18. }
  19. }
  20. }