diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/CalculatorDemo.csproj b/Samples/Islands/DrawingIsland/CalculatorDemo/CalculatorDemo.csproj index 5740076b3..2778ec86c 100644 --- a/Samples/Islands/DrawingIsland/CalculatorDemo/CalculatorDemo.csproj +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/CalculatorDemo.csproj @@ -113,6 +113,7 @@ Settings.settings True + ResXFileCodeGenerator Resources.Designer.cs diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.xaml b/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.xaml index ed2ecbb9b..31a9886bc 100644 --- a/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.xaml +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.xaml @@ -137,7 +137,9 @@ Also, make the TextBox borders a little less harsh. --> - + + + diff --git a/Samples/Islands/DrawingIsland/CalculatorDemo/WpfIslandHost.cs b/Samples/Islands/DrawingIsland/CalculatorDemo/WpfIslandHost.cs new file mode 100644 index 000000000..34bf02a09 --- /dev/null +++ b/Samples/Islands/DrawingIsland/CalculatorDemo/WpfIslandHost.cs @@ -0,0 +1,34 @@ +using Microsoft.UI.Composition; +using Microsoft.UI.Content; +using System.Runtime.InteropServices; +using System.Windows.Interop; + +namespace CalculatorDemo +{ + internal class WpfIslandHost : HwndHost + { + public WpfIslandHost(Compositor compositor) + { + _compositor = compositor; + } + + public DesktopChildSiteBridge DesktopChildSiteBridge { get; private set; } + + protected override HandleRef BuildWindowCore(HandleRef hwndParent) + { + DesktopChildSiteBridge = Microsoft.UI.Content.DesktopChildSiteBridge.Create( + _compositor, + new Microsoft.UI.WindowId((ulong)hwndParent.Handle)); + + return new HandleRef(null, (nint)DesktopChildSiteBridge.WindowId.Value); + } + + protected override void DestroyWindowCore(HandleRef hwnd) + { + DesktopChildSiteBridge.Dispose(); + DesktopChildSiteBridge = null; + } + + Microsoft.UI.Composition.Compositor _compositor; + } +} \ No newline at end of file