Пример #1
0
        internal static IWindow?GetWindowForXamlRoot(XamlRoot?root)
        {
            if (root is null)
            {
                return(null);
            }

            var windows = WindowExtensions.GetWindows();

            foreach (var window in windows)
            {
                if (window.Handler?.PlatformView is Microsoft.UI.Xaml.Window win)
                {
                    if (win.Content?.XamlRoot == root)
                    {
                        return(window);
                    }
                }
            }

            return(null);
        }
Пример #2
0
        internal static IWindow?GetHostedWindow(this UIWindow?uiWindow)
        {
            if (uiWindow is null)
            {
                return(null);
            }

            var windows = WindowExtensions.GetWindows();

            foreach (var window in windows)
            {
                if (window.Handler?.PlatformView is UIWindow win)
                {
                    if (win == uiWindow)
                    {
                        return(window);
                    }
                }
            }

            return(null);
        }