From d5e99673b50248314a9826b2d750235c607464fb Mon Sep 17 00:00:00 2001 From: Dan Siegel Date: Thu, 29 Feb 2024 06:34:14 -0600 Subject: [PATCH] chore: update PageDialogService to use the new Current Window API --- .../Services/PageDialogs/PageDialogService.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Maui/Prism.Maui/Services/PageDialogs/PageDialogService.cs b/src/Maui/Prism.Maui/Services/PageDialogs/PageDialogService.cs index a6bfd54dde..95faeac8ab 100644 --- a/src/Maui/Prism.Maui/Services/PageDialogs/PageDialogService.cs +++ b/src/Maui/Prism.Maui/Services/PageDialogs/PageDialogService.cs @@ -1,5 +1,4 @@ -using Prism.AppModel; -using Prism.Common; +using Prism.AppModel; using Prism.Navigation; using FlowDirection = Prism.AppModel.FlowDirection; using MauiFlow = Microsoft.Maui.FlowDirection; @@ -181,5 +180,11 @@ public virtual Task DisplayPromptAsync(string title, string message, str return GetPage().DisplayPromptAsync(title, message, accept, cancel, placeholder, maxLength, keyboard, initialValue); } - private Page GetPage() => _windowManager.Windows.OfType().First().CurrentPage; + private Page GetPage() + { + if (_windowManager.Current is not PrismWindow window) + throw new InvalidOperationException("There is no Prism Window currently displayed."); + + return window.CurrentPage; + } }