Skip to content

Commit 135236c

Browse files
committed
Calc: Step 6.1: Prepare for DrawingIsland - Add WpfIslandHost.cs and DisplayAreaBorder element
1 parent 0e9a3cc commit 135236c

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

Samples/Islands/DrawingIsland/CalculatorDemo/CalculatorDemo.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
<DependentUpon>Settings.settings</DependentUpon>
114114
<DesignTimeSharedInput>True</DesignTimeSharedInput>
115115
</Compile>
116+
<Compile Include="WpfIslandHost.cs" />
116117
<EmbeddedResource Include="Properties\Resources.resx">
117118
<Generator>ResXFileCodeGenerator</Generator>
118119
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using Microsoft.UI.Composition;
2+
using Microsoft.UI.Content;
3+
using System.Runtime.InteropServices;
4+
using System.Windows.Interop;
5+
6+
namespace CalculatorDemo
7+
{
8+
internal class WpfIslandHost : HwndHost
9+
{
10+
public WpfIslandHost(Compositor compositor)
11+
{
12+
_compositor = compositor;
13+
}
14+
15+
public DesktopChildSiteBridge DesktopChildSiteBridge { get; private set; }
16+
17+
protected override HandleRef BuildWindowCore(HandleRef hwndParent)
18+
{
19+
DesktopChildSiteBridge = Microsoft.UI.Content.DesktopChildSiteBridge.Create(
20+
_compositor,
21+
new Microsoft.UI.WindowId((ulong)hwndParent.Handle));
22+
23+
return new HandleRef(null, (nint)DesktopChildSiteBridge.WindowId.Value);
24+
}
25+
26+
protected override void DestroyWindowCore(HandleRef hwnd)
27+
{
28+
DesktopChildSiteBridge.Dispose();
29+
DesktopChildSiteBridge = null;
30+
}
31+
32+
Microsoft.UI.Composition.Compositor _compositor;
33+
}
34+
}

0 commit comments

Comments
 (0)