Hello,
I noticed that you're using the WinUI2 API calling method, while MAUI programs are based on WinUI3 on Windows, and the way MessageDialog
is called is slightly different between them.
Please refer to User interface migration (including WinUI 3) - MessageDialog, and Pickers to get more details.
The following is a code examples:
using var process = Process.GetCurrentProcess();
var hwnd = process.MainWindowHandle;
var showDialog = new MessageDialog("Message here");
WinRT.Interop.InitializeWithWindow.Initialize(showDialog, hwnd);
await showDialog.ShowAsync();
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.