Skip to content

Commit 0eebe88

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

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
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>

Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.xaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@
137137
Also, make the TextBox borders a little less harsh.
138138
-->
139139
<local:MyTextBox Grid.ColumnSpan="9" x:Name="DisplayBox" Height="30" Margin="5" FontSize="20" BorderBrush="LightGray"/>
140-
<local:MyTextBox Grid.Row="1" Grid.ColumnSpan="3" Grid.RowSpan="5" Margin="5" x:Name="PaperBox" BorderBrush="LightGray"/>
140+
<Border Name="DisplayAreaBorder" Grid.Row="1" Grid.ColumnSpan="3" Grid.RowSpan="5" Margin="5">
141+
<local:MyTextBox x:Name="PaperBox" BorderBrush="LightGray"/>
142+
</Border>
141143
</Grid>
142144

143145
</DockPanel>
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)