Skip to content

Commit 90a4cdf

Browse files
committed
Complete working WpfCalculator app with packaging and WASDK additions
1 parent fc62c9a commit 90a4cdf

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+4206
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<configuration>
4+
<startup>
5+
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
6+
</startup>
7+
</configuration>
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// // Copyright (c) Microsoft. All rights reserved.
2+
// // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
4+
using Microsoft.UI.Dispatching;
5+
using System.Windows;
6+
7+
namespace CalculatorDemo
8+
{
9+
/// <summary>
10+
/// Interaction logic for App.xaml
11+
/// </summary>
12+
public partial class App : Application
13+
{
14+
// Many WinAppSDK APIs require a DispatcherQueue to be running on the thread. We'll start one when the app starts up
15+
// and shut it down when the app is finished.
16+
protected override void OnStartup(StartupEventArgs e)
17+
{
18+
_dispatcherQueueController = DispatcherQueueController.CreateOnCurrentThread();
19+
base.OnStartup(e);
20+
}
21+
22+
protected override void OnExit(ExitEventArgs e)
23+
{
24+
base.OnExit(e);
25+
_dispatcherQueueController?.ShutdownQueue();
26+
_dispatcherQueueController = null;
27+
}
28+
29+
DispatcherQueueController? _dispatcherQueueController;
30+
}
31+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<Application x:Class="CalculatorDemo.App"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
StartupUri="MainWindow.xaml">
5+
<!--
6+
We add the below ResourceDictionary to our Application's Merged
7+
ResourceDictionaries so that our app will pick up the new styles. The
8+
pack URI
9+
(https://learn.microsoft.com/en-us/dotnet/desktop/wpf/app-development/pack-uris-in-wpf)
10+
below tells WPF to open the referenced assembly named
11+
"PresentationFramework.Fluent.dll" and read a Xaml resource from it.
12+
-->
13+
<Application.Resources>
14+
<ResourceDictionary>
15+
<ResourceDictionary.MergedDictionaries>
16+
<ResourceDictionary
17+
Source="pack://application:,,,/PresentationFramework.Fluent;component/Resources/Fluent.xaml" />
18+
</ResourceDictionary.MergedDictionaries>
19+
</ResourceDictionary>
20+
</Application.Resources>
21+
</Application>
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<!-- WinAppSDK requires at least the 17763 build of windows, so we need to set that here.
4+
You can set this in the Visual Studio project properties UI too. -->
5+
<TargetFramework>net9.0-windows10.0.22621.0</TargetFramework>
6+
<UseWpf>true</UseWpf>
7+
<EnableDefaultItems>false</EnableDefaultItems>
8+
<Platforms>x64;ARM64;x86</Platforms>
9+
10+
<!-- When adding a reference to WinAppSDK, we need to enable only the RIDs for the platforms WinAppSDK supprts. -->
11+
<RuntimeIdentifiers>win-x64;win-x86;win-arm64</RuntimeIdentifiers>
12+
13+
<!-- These flags turn off some WinAppSDK features we won't be using. -->
14+
<UseWinUITools>false</UseWinUITools>
15+
<EnableCoreMrtTooling>false</EnableCoreMrtTooling>
16+
</PropertyGroup>
17+
<PropertyGroup>
18+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
19+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
20+
<ProjectGuid>{5731865D-6685-47A7-8877-5DBAF39B54CD}</ProjectGuid>
21+
<OutputType>WinExe</OutputType>
22+
<AppDesignerFolder>Properties</AppDesignerFolder>
23+
<RootNamespace>CalculatorDemo</RootNamespace>
24+
<AssemblyName>CalculatorDemo</AssemblyName>
25+
<FileAlignment>512</FileAlignment>
26+
<WarningLevel>4</WarningLevel>
27+
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
28+
</PropertyGroup>
29+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
30+
<PlatformTarget>AnyCPU</PlatformTarget>
31+
<DebugSymbols>true</DebugSymbols>
32+
<DebugType>portable</DebugType>
33+
<Optimize>false</Optimize>
34+
<OutputPath>bin\Debug\</OutputPath>
35+
<DefineConstants>DEBUG;TRACE</DefineConstants>
36+
<ErrorReport>prompt</ErrorReport>
37+
<WarningLevel>4</WarningLevel>
38+
</PropertyGroup>
39+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
40+
<PlatformTarget>AnyCPU</PlatformTarget>
41+
<DebugSymbols>true</DebugSymbols>
42+
<DebugType>portable</DebugType>
43+
<Optimize>false</Optimize>
44+
<OutputPath>bin\Debug\</OutputPath>
45+
<DefineConstants>DEBUG;TRACE</DefineConstants>
46+
<ErrorReport>prompt</ErrorReport>
47+
<WarningLevel>4</WarningLevel>
48+
</PropertyGroup>
49+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
50+
<PlatformTarget>AnyCPU</PlatformTarget>
51+
<DebugSymbols>true</DebugSymbols>
52+
<DebugType>portable</DebugType>
53+
<Optimize>false</Optimize>
54+
<OutputPath>bin\Debug\</OutputPath>
55+
<DefineConstants>DEBUG;TRACE</DefineConstants>
56+
<ErrorReport>prompt</ErrorReport>
57+
<WarningLevel>4</WarningLevel>
58+
</PropertyGroup>
59+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x86'">
60+
<PlatformTarget>AnyCPU</PlatformTarget>
61+
<DebugType>pdbonly</DebugType>
62+
<Optimize>true</Optimize>
63+
<OutputPath>bin\Release\</OutputPath>
64+
<DefineConstants>TRACE</DefineConstants>
65+
<ErrorReport>prompt</ErrorReport>
66+
<WarningLevel>4</WarningLevel>
67+
</PropertyGroup>
68+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
69+
<PlatformTarget>AnyCPU</PlatformTarget>
70+
<DebugType>pdbonly</DebugType>
71+
<Optimize>true</Optimize>
72+
<OutputPath>bin\Release\</OutputPath>
73+
<DefineConstants>TRACE</DefineConstants>
74+
<ErrorReport>prompt</ErrorReport>
75+
<WarningLevel>4</WarningLevel>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
78+
<PlatformTarget>AnyCPU</PlatformTarget>
79+
<DebugType>pdbonly</DebugType>
80+
<Optimize>true</Optimize>
81+
<OutputPath>bin\Release\</OutputPath>
82+
<DefineConstants>TRACE</DefineConstants>
83+
<ErrorReport>prompt</ErrorReport>
84+
<WarningLevel>4</WarningLevel>
85+
</PropertyGroup>
86+
<ItemGroup>
87+
<ApplicationDefinition Include="App.xaml">
88+
<Generator>MSBuild:Compile</Generator>
89+
<SubType>Designer</SubType>
90+
</ApplicationDefinition>
91+
<Page Include="MainWindow.xaml">
92+
<Generator>MSBuild:Compile</Generator>
93+
<SubType>Designer</SubType>
94+
</Page>
95+
<Compile Include="App.cs">
96+
<DependentUpon>App.xaml</DependentUpon>
97+
<SubType>Code</SubType>
98+
</Compile>
99+
<Compile Include="MainWindow.cs">
100+
<DependentUpon>MainWindow.xaml</DependentUpon>
101+
<SubType>Code</SubType>
102+
</Compile>
103+
</ItemGroup>
104+
<ItemGroup>
105+
<Compile Include="MyTextBox.cs" />
106+
<Compile Include="Properties\Resources.Designer.cs">
107+
<AutoGen>True</AutoGen>
108+
<DesignTime>True</DesignTime>
109+
<DependentUpon>Resources.resx</DependentUpon>
110+
</Compile>
111+
<Compile Include="Properties\Settings.Designer.cs">
112+
<AutoGen>True</AutoGen>
113+
<DependentUpon>Settings.settings</DependentUpon>
114+
<DesignTimeSharedInput>True</DesignTimeSharedInput>
115+
</Compile>
116+
<Compile Include="WpfIslandHost.cs" />
117+
<EmbeddedResource Include="Properties\Resources.resx">
118+
<Generator>ResXFileCodeGenerator</Generator>
119+
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
120+
</EmbeddedResource>
121+
<None Include="Properties\Settings.settings">
122+
<Generator>SettingsSingleFileGenerator</Generator>
123+
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
124+
</None>
125+
<AppDesigner Include="Properties\" />
126+
</ItemGroup>
127+
<ItemGroup>
128+
<None Include="App.config" />
129+
</ItemGroup>
130+
<ItemGroup>
131+
<PackageReference Include="Microsoft.Windows.CsWinRT" Version="2.0.7" />
132+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.5.240428000" />
133+
</ItemGroup>
134+
<ItemGroup>
135+
<ProjectReference Include="..\DrawingIslandCsProjection\DrawingIslandCsProjection.csproj" />
136+
</ItemGroup>
137+
<ItemGroup>
138+
<Resource Include="appicon.ico" />
139+
</ItemGroup>
140+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
141+
Other similar extension points exist, see Microsoft.Common.targets.
142+
<Target Name="BeforeBuild">
143+
</Target>
144+
<Target Name="AfterBuild">
145+
</Target>
146+
-->
147+
</Project>

0 commit comments

Comments
 (0)