【UWP】让 UWP 自己托管自己 —— Windows SDK 篇
众所周知,UWP 使用的窗口模型是 CoreWindow,但是 UWP 本身只是一个应用模型,所以完全可以创建 win32 窗口,那么我们可以不可以创建一个 win32 窗口,然后像 XAML 岛 (XAML Islands) 一样把 XAML 托管上去呢?本篇将讲述如何在 UWP 创建一个 XAML 岛窗口。 首先,XAML 岛会判断当前的应用模型是否为 ClassicDesktop ,所以我们需要利用 Detours 劫持 AppPolicyGetWindowingModel 方法。具体内容如下: #r "nuget:Detours.Win32Metadata" #r "nuget:Microsoft.Windows.CsWin32" using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using Windows.Win32; using Windows.Win32.Foundation; using Windows.Win32.Storage.Packaging.Appx; using Detours = Microsoft.Detours.PInvoke; /// <summary> /// Represents a hook for the <see cref="PInvoke.AppPolicyGetWindowingModel(HANDLE, AppPolicyWindowingModel*)"/> function. /// </summary> public sealed partial class HookWindowingModel : IDisposable { /// <summary> /// The value that indicates whether the class has been disposed. /// </summary> private bo...