Skip to content

Add WpfCalculator app in a parallel directory to DrawingIsland, with steps #353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 49 commits into
base: user/jeffstall/drawingisland
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
fc62c9a
Add nuget.config entry for .net9
JesseCol May 8, 2024
90a4cdf
Complete working WpfCalculator app with packaging and WASDK additions
JesseCol May 9, 2024
3330176
Remove the hardcoded size for the compact overlay
JesseCol May 9, 2024
d7fe0db
Improve workaround in wapproj
JesseCol May 9, 2024
07b3393
Add demo steps
JesseCol May 9, 2024
bba7d97
Add another comment
JesseCol May 9, 2024
fae1230
readme
JesseCol May 9, 2024
7b3a154
More step comments
JesseCol May 9, 2024
876d976
More step comments
JesseCol May 9, 2024
1ebb414
readme
JesseCol May 9, 2024
0279130
Improve Demo4_Step2_AddIsland
JesseCol May 9, 2024
c686112
PR feedback: organize usings, and remove AnyCPU
JesseCol May 10, 2024
140855a
Port latest Text changes
jeffstall May 10, 2024
3a516e6
Merge branch 'user/jessecol/calc-app' of https://github.com/microsoft…
jeffstall May 10, 2024
260700b
Turn everyone on for testing
jeffstall May 10, 2024
9c03c97
Latest fixes from Niklas
jeffstall May 10, 2024
38ccb7e
Split demos into different partial files
jeffstall May 10, 2024
b9cfdf1
Merge remote-tracking branch 'origin/user/jeffstall/drawingisland' in…
JesseCol May 10, 2024
ed98180
Add Lottie Island to WpfCalculator
JesseCol May 10, 2024
d35d72b
Add SceneNodeIsland, but it hangs :-(
JesseCol May 10, 2024
6d3df7a
Work around for async loading in WPF
jeffstall May 11, 2024
9f4aec3
Minor clean-up for //build
jeffstall May 13, 2024
cc4f50d
//build start
jeffstall May 14, 2024
df06074
Updated //build steps
jeffstall May 15, 2024
d0ea9c0
Clean up for //build demo
jeffstall May 18, 2024
871aabb
Move files unused for //build
jeffstall May 18, 2024
6a36d7b
Handle transparent rendering in WPF.
jeffstall May 18, 2024
50adf5c
Fix for WPF transparent rendering
jeffstall May 18, 2024
cac50ed
Make compact calc better
JesseCol May 19, 2024
3fd34bd
Cleanup and make RS5
jeffstall May 20, 2024
96fc451
Make the calc work in compact mode
JesseCol May 20, 2024
2ce727c
Remove code in UpdateDisplay to update CompactViewText manually
JesseCol May 20, 2024
26c31a9
Change layout to make it look good at the same size as the original calc
JesseCol May 20, 2024
5f17057
Remove extra changes I inlcuded for the layout change
JesseCol May 20, 2024
e55aef4
Fix the demo to start at zero and have the smaller layout.
JesseCol May 20, 2024
248173e
Fix app.xaml to work with .net9
Nov 14, 2024
30ce5f8
Remove .net entry from nuget.config
Nov 14, 2024
c0553eb
Add DrawingIslandCSProjection to sln
Nov 14, 2024
de0e13b
Update to WinAppSDK 1.6
Nov 14, 2024
6e0e619
Update DrawingIsland to WASDK 1.6
Nov 14, 2024
2969af0
Turn ON all the steps
Nov 14, 2024
9d01df8
Update comments for Ignite demo script
jeffstall Nov 15, 2024
2d8bcbf
START 11-14-2024
jeffstall Nov 15, 2024
bf3e795
START 11-14-2024 (B): Fix DrawingIsland
jeffstall Nov 15, 2024
b00c6e0
Move to WinAppSDK 1.6.1
Nov 15, 2024
ce2268e
Use ThemeMode API instead of pack URI
Nov 16, 2024
7b2c2c0
Set DpiMode to per-mon-v2, include comentted code to turn off the bac…
Nov 17, 2024
01c8297
LKG 2024-11-17 Refine start
jeffstall Nov 18, 2024
fcc3bd9
LKG: 2024-11-19 Simplify
jeffstall Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.props')" />
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.props')" />
<Import Project="..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props')" />
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
Expand Down Expand Up @@ -133,7 +133,8 @@
<ImportGroup Label="ExtensionTargets">
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets')" />
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.2651.64\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2651.64\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand All @@ -143,7 +144,8 @@
<Error Condition="!Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.2651.64\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2651.64\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.targets'))" />
</Target>
</Project>
12 changes: 6 additions & 6 deletions Samples/Islands/DrawingIsland/DrawingCppTestApp/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
auto controller{ winrt::DispatcherQueueController::CreateOnCurrentThread() };
auto queue = controller.DispatcherQueue();

// Associating the AppWindow with the DispatcherQueue on which the ContentIsland is created
// will ensure that the ContentIsland is Closed when the AppWindow closes.
// Associate the AppWindow's lifetime with the DispatcherQueue to automatically close on exit.
auto window = winrt::AppWindow::Create();
window.AssociateWithDispatcherQueue(queue);
window.Closing(
Expand All @@ -35,20 +34,21 @@ int __stdcall wWinMain(HINSTANCE, HINSTANCE, PWSTR, int)
window.Title(L"Drawing C++ TestApp");
window.Show();

// Create the Island content in the window.
auto compositor = winrt::Compositor();
auto island = winrt::DrawingIsland(compositor).Island();

#pragma region ...
// Create a ContentSiteBridge and connect the ContentIsland to it.
auto compositor = winrt::Compositor();
auto siteBridge = winrt::DesktopChildSiteBridge::Create(compositor, window.Id());
siteBridge.ResizePolicy(winrt::ContentSizePolicy::ResizeContentToParentWindow);
siteBridge.Show();

auto island = winrt::DrawingIsland(compositor).Island();
siteBridge.Connect(island);

// Move initial focus to the ContentIsland.
auto focusNavigationHost = winrt::InputFocusNavigationHost::GetForSiteBridge(siteBridge);
focusNavigationHost.NavigateFocus(winrt::FocusNavigationRequest::Create(
winrt::FocusNavigationReason::Programmatic));
#pragma endregion

queue.RunEventLoop();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.2651.64" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.SDK.BuildTools" version="10.0.22621.3233" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.5.240428000" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.6.240923002" targetFramework="native" />
</packages>
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@
<Optimize>False</Optimize>
</PropertyGroup>

<ItemGroup>
<Compile Remove="DuckScenario.cs" />
</ItemGroup>

<ItemGroup>
<!-- Added CsWinRT reference to avoid WinMD error as a result of WinMD leaking via project reference. -->
<PackageReference Include="CommunityToolkit.WinAppSDK.LottieWinRT" Version="8.0.230819-rc-LottieIsland.7.g92a87e1883" />
Expand Down
40 changes: 15 additions & 25 deletions Samples/Islands/DrawingIsland/DrawingCsTestApp/Program.cs
Original file line number Diff line number Diff line change
@@ -1,62 +1,52 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

#region Using directives
using Microsoft.UI.Composition;
using Microsoft.UI.Content;
using Microsoft.UI.Dispatching;
using Microsoft.UI.Input;
using Microsoft.UI.Windowing;

using DrawingIslandComponents;
#endregion

var controller = DispatcherQueueController.CreateOnCurrentThread();
var queue = controller.DispatcherQueue;

// Associate the AppWindow's lifetime with the DispatcherQueue to automatically close on exit.
var window = AppWindow.Create();
window.AssociateWithDispatcherQueue(queue);
window.Closing +=(sender, args) =>
{
// Ensure the DispatcherQueue exits the event loop on close.
queue.EnqueueEventLoopExit();
};

window.Title = "Drawing C# .NET TestApp";
window.Show();

#region ...
// Create a ContentSiteBridge and connect Island content into it.
var compositor = new Compositor();

var siteBridge = DesktopChildSiteBridge.Create(compositor, window.Id);
siteBridge.ResizePolicy = ContentSizePolicy.ResizeContentToParentWindow;
siteBridge.Show();

if (args.Contains("Lottie"))
{
// LottieIsland
var lottie = LottieIslandScenario.CreateLottieIsland(compositor);
siteBridge.Connect(lottie.Island);
}
else if (args.Contains("Duck"))
{
// SceneNodeIsland
var island = DuckScenario.CreateIsland(compositor);
siteBridge.Connect(island);
}
else if (args.Contains("Helmet"))
{
// SceneNodeIsland
var island = HelmetScenario.CreateIsland(compositor);
siteBridge.Connect(island);
}
else
{
// DrawingIsland
var drawing = new DrawingIsland(compositor);
siteBridge.Connect(drawing.Island);
}
var lottie = LottieIslandScenario.CreateLottieIsland(compositor);
siteBridge.Connect(lottie.Island);

#region ...
//var island = HelmetScenario.CreateIsland(compositor);
//siteBridge.Connect(island);

#endregion

// Move initial focus to the island.
var focusNavigationHost = InputFocusNavigationHost.GetForSiteBridge(siteBridge);
focusNavigationHost.NavigateFocus(FocusNavigationRequest.Create(
FocusNavigationReason.Programmatic));
#endregion

queue.RunEventLoop();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.props')" />
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.props" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.props')" />
<Import Project="..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props" Condition="Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props')" />
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.props')" />
<PropertyGroup Label="Globals">
Expand Down Expand Up @@ -171,7 +171,8 @@
<Import Project="..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('..\packages\Microsoft.Windows.CppWinRT.2.0.240405.15\build\native\Microsoft.Windows.CppWinRT.targets')" />
<Import Project="..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets" Condition="Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets')" />
<Import Project="..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240122.1\build\native\Microsoft.Windows.ImplementationLibrary.targets" Condition="Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240122.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" />
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.targets')" />
<Import Project="..\packages\Microsoft.Web.WebView2.1.0.2651.64\build\native\Microsoft.Web.WebView2.targets" Condition="Exists('..\packages\Microsoft.Web.WebView2.1.0.2651.64\build\native\Microsoft.Web.WebView2.targets')" />
<Import Project="..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.targets" Condition="Exists('..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
Expand All @@ -182,7 +183,8 @@
<Error Condition="!Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.SDK.BuildTools.10.0.22621.3233\build\Microsoft.Windows.SDK.BuildTools.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240122.1\build\native\Microsoft.Windows.ImplementationLibrary.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Windows.ImplementationLibrary.1.0.240122.1\build\native\Microsoft.Windows.ImplementationLibrary.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.5.240428000\build\native\Microsoft.WindowsAppSDK.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.Web.WebView2.1.0.2651.64\build\native\Microsoft.Web.WebView2.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Web.WebView2.1.0.2651.64\build\native\Microsoft.Web.WebView2.targets'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.WindowsAppSDK.1.6.240923002\build\native\Microsoft.WindowsAppSDK.targets'))" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Web.WebView2" version="1.0.2651.64" targetFramework="native" />
<package id="Microsoft.Windows.CppWinRT" version="2.0.240405.15" targetFramework="native" />
<package id="Microsoft.Windows.ImplementationLibrary" version="1.0.240122.1" targetFramework="native" />
<package id="Microsoft.Windows.SDK.BuildTools" version="10.0.22621.3233" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.5.240428000" targetFramework="native" />
<package id="Microsoft.WindowsAppSDK" version="1.6.240923002" targetFramework="native" />
</packages>
7 changes: 7 additions & 0 deletions Samples/Islands/WpfCalculator/CalculatorDemo/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>

<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
15 changes: 15 additions & 0 deletions Samples/Islands/WpfCalculator/CalculatorDemo/App.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Windows;

namespace CalculatorDemo
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{

}
}
17 changes: 17 additions & 0 deletions Samples/Islands/WpfCalculator/CalculatorDemo/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Application x:Class="CalculatorDemo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml">

<!-- Demo2_Step1_AddTheming
We set ThemeMode to "System" so give the app Win11 styles that match the
system light/dark theme.
-->
<!--<Application x:Class="CalculatorDemo.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"
ThemeMode="System"
>-->

</Application>
29 changes: 29 additions & 0 deletions Samples/Islands/WpfCalculator/CalculatorDemo/App_Demo3.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Windows;
using Microsoft.UI.Dispatching;

// Demo3_Step1_AddWasdk
namespace CalculatorDemo
{
public partial class App : Application
{
// Many WinAppSDK APIs require a DispatcherQueue to be running on the thread. We'll start
// one when the app starts up and shut it down when the app is finished.
protected override void OnStartup(StartupEventArgs e)
{
_dispatcherQueueController = DispatcherQueueController.CreateOnCurrentThread();
base.OnStartup(e);
}

protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
_dispatcherQueueController?.ShutdownQueue();
_dispatcherQueueController = null;
}

DispatcherQueueController? _dispatcherQueueController;
}
}
Loading