Skip to content

Commit 04c8407

Browse files
committed
Calc: Step 6.2: Add a DrawingIsland
1 parent 135236c commit 04c8407

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,15 @@ public sealed partial class MainWindow : Window
2323
private string _lastVal;
2424
private string _memVal;
2525
private AppWindow _appWindow;
26+
private Microsoft.UI.Composition.Compositor _compositor;
2627

2728
public MainWindow()
2829
{
2930
InitializeComponent();
3031
_paper = new PaperTrail(this);
3132
ProcessKey('0');
3233
EraseDisplay = true;
34+
_compositor = new Microsoft.UI.Composition.Compositor();
3335
}
3436

3537
/// <summary>
@@ -489,5 +491,16 @@ void SetCompactView(bool useCompactView)
489491
_appWindow.SetPresenter(AppWindowPresenterKind.Default);
490492
}
491493
}
494+
495+
private void CreateDrawingIslandMenuItem_Click(object sender, RoutedEventArgs e)
496+
{
497+
var wpfIslandHost = new WpfIslandHost(_compositor);
498+
var drawingIsland = new DrawingIslandComponents.DrawingIsland(_compositor);
499+
500+
// After this, the WpfIslandHost will be live, and the DesktopChildSiteBridge will be available.
501+
DisplayAreaBorder.Child = wpfIslandHost;
502+
503+
wpfIslandHost.DesktopChildSiteBridge.Connect(drawingIsland.Island);
504+
}
492505
}
493506
}

Samples/Islands/DrawingIsland/CalculatorDemo/MainWindow.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
-->
3939
<Menu Name="MainMenu" DockPanel.Dock="Top">
4040
<MenuItem Header="File">
41+
<MenuItem Name="CreateDrawingIslandMenuItem" Click="CreateDrawingIslandMenuItem_Click" Header="Create DrawingIsland" />
4142
<MenuItem Click="OnMenuExit" Header="Exit" />
4243
</MenuItem>
4344
<MenuItem Header="View">

0 commit comments

Comments
 (0)