I need to get a reference to the parent Microsoft.UI.Xaml.Window
for a Control
. Is there a way to do that in Project Reunion 0.5? Window.Current
does not work in a desktop app.
On WinUI3 since the window is platform-dependent you access it differently. For Windows Desktop it uses Win32Inerop:
private AppWindow GetAppWindowForCurrentWindow()
{
IntPtr hWnd = WindowNative.GetWindowHandle(this);
WindowId wndId = Win32Interop.GetWindowIdFromWindow(hWnd);
return AppWindow.GetFromWindowId(wndId);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.