Reputation: 13723
I've started playing with the latest RC release of .NET MAUI. I wish to migrate a Windows application I have, so later on it could be multi-platform. For Windows, my application needs to get the handle for a controller (then passed to a 3rd party library that makes use of it).
In my WinForms application what I usually do is something like IntPtr controlHandle = MyControl.Handle;
Is it possible to get the Handle on a control in .NET MAUI? I remember in the past checking this for a WPF application and for all controls it returned the main window handle address, but there was a way to create a new control with it's own handle. Is there such possibility in MAUI?
Upvotes: 2
Views: 1651
Reputation: 21
just in case someone is still trying to figure this out.
// Get the current window's HWND by passing in the Window object
var hwnd = ((MauiWinUIWindow)App.Current.Windows[0].Handler.NativeView).WindowHandle;
references: https://blog.verslu.is/maui/folder-picker-with-dotnet-maui/ https://devblogs.microsoft.com/oldnewthing/20190412-00/?p=102413
Upvotes: 2