diff --git a/src/Uno.UWP/UI/Popups/MessageDialog.Interop.wasm.cs b/src/Uno.UWP/UI/Popups/MessageDialog.Interop.wasm.cs index 245fd67dc871..3bfa16a52d79 100644 --- a/src/Uno.UWP/UI/Popups/MessageDialog.Interop.wasm.cs +++ b/src/Uno.UWP/UI/Popups/MessageDialog.Interop.wasm.cs @@ -7,7 +7,9 @@ internal partial class MessageDialog { internal static partial class NativeMethods { + [JSImport("globalThis.alert")] + internal static partial void Alert(string message); } } } -#endif \ No newline at end of file +#endif diff --git a/src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs b/src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs index 907726332374..e59520ca5e57 100644 --- a/src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs +++ b/src/Uno.UWP/UI/Popups/MessageDialog.wasm.cs @@ -23,8 +23,12 @@ private IAsyncOperation ShowNativeAsync(CancellationToken ct) { VisualTreeHelperProxy.CloseAllFlyouts(); +#if NET7_0_OR_GREATER + NativeMethods.Alert(Content); +#else var command = $"Uno.UI.WindowManager.current.alert(\"{Uno.Foundation.WebAssemblyRuntime.EscapeJs(Content)}\");"; Uno.Foundation.WebAssemblyRuntime.InvokeJS(command); +#endif return AsyncOperation.FromTask( ct => Task.FromResult(new UICommand("OK")) // TODO: Localize (PBI 28711)