Skip to content

Commit a7814f9

Browse files
authored
Added WinUI sample (#24)
* Basic WinUI3 application
1 parent 93946b5 commit a7814f9

30 files changed

+988
-0
lines changed

samples/todoapp/Samples.TodoApp.sln

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "library", "library", "{7183ECEC-9F44-48CE-BB97-AA2445170D5E}"
7+
EndProject
8+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TodoApp.WinUI3", "TodoApp.WinUI3\TodoApp.WinUI3.csproj", "{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}"
9+
EndProject
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.Client", "..\..\src\CommunityToolkit.Datasync.Client\CommunityToolkit.Datasync.Client.csproj", "{2AC73FBE-9E76-4702-B551-B5884383CC68}"
11+
EndProject
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CommunityToolkit.Datasync.Server.Abstractions", "..\..\src\CommunityToolkit.Datasync.Server.Abstractions\CommunityToolkit.Datasync.Server.Abstractions.csproj", "{C99C342C-FDAC-46DC-89B2-A06CB008348E}"
13+
EndProject
14+
Global
15+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
16+
Debug|Any CPU = Debug|Any CPU
17+
Debug|ARM64 = Debug|ARM64
18+
Debug|x64 = Debug|x64
19+
Debug|x86 = Debug|x86
20+
Release|Any CPU = Release|Any CPU
21+
Release|ARM64 = Release|ARM64
22+
Release|x64 = Release|x64
23+
Release|x86 = Release|x86
24+
EndGlobalSection
25+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
26+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|Any CPU.ActiveCfg = Debug|x64
27+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|Any CPU.Build.0 = Debug|x64
28+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|Any CPU.Deploy.0 = Debug|x64
29+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|ARM64.ActiveCfg = Debug|ARM64
30+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|ARM64.Build.0 = Debug|ARM64
31+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|ARM64.Deploy.0 = Debug|ARM64
32+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|x64.ActiveCfg = Debug|x64
33+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|x64.Build.0 = Debug|x64
34+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|x64.Deploy.0 = Debug|x64
35+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|x86.ActiveCfg = Debug|x86
36+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|x86.Build.0 = Debug|x86
37+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Debug|x86.Deploy.0 = Debug|x86
38+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|Any CPU.ActiveCfg = Release|x64
39+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|Any CPU.Build.0 = Release|x64
40+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|Any CPU.Deploy.0 = Release|x64
41+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|ARM64.ActiveCfg = Release|ARM64
42+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|ARM64.Build.0 = Release|ARM64
43+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|ARM64.Deploy.0 = Release|ARM64
44+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|x64.ActiveCfg = Release|x64
45+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|x64.Build.0 = Release|x64
46+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|x64.Deploy.0 = Release|x64
47+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|x86.ActiveCfg = Release|x86
48+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|x86.Build.0 = Release|x86
49+
{D783EDE7-D3A2-44D3-8C97-38AFFF9A4555}.Release|x86.Deploy.0 = Release|x86
50+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Debug|ARM64.ActiveCfg = Debug|Any CPU
53+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Debug|ARM64.Build.0 = Debug|Any CPU
54+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Debug|x64.ActiveCfg = Debug|Any CPU
55+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Debug|x64.Build.0 = Debug|Any CPU
56+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Debug|x86.ActiveCfg = Debug|Any CPU
57+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Debug|x86.Build.0 = Debug|Any CPU
58+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Release|Any CPU.ActiveCfg = Release|Any CPU
59+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Release|Any CPU.Build.0 = Release|Any CPU
60+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Release|ARM64.ActiveCfg = Release|Any CPU
61+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Release|ARM64.Build.0 = Release|Any CPU
62+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Release|x64.ActiveCfg = Release|Any CPU
63+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Release|x64.Build.0 = Release|Any CPU
64+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Release|x86.ActiveCfg = Release|Any CPU
65+
{2AC73FBE-9E76-4702-B551-B5884383CC68}.Release|x86.Build.0 = Release|Any CPU
66+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
67+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Debug|Any CPU.Build.0 = Debug|Any CPU
68+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
69+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Debug|ARM64.Build.0 = Debug|Any CPU
70+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Debug|x64.ActiveCfg = Debug|Any CPU
71+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Debug|x64.Build.0 = Debug|Any CPU
72+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Debug|x86.ActiveCfg = Debug|Any CPU
73+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Debug|x86.Build.0 = Debug|Any CPU
74+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Release|Any CPU.ActiveCfg = Release|Any CPU
75+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Release|Any CPU.Build.0 = Release|Any CPU
76+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Release|ARM64.ActiveCfg = Release|Any CPU
77+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Release|ARM64.Build.0 = Release|Any CPU
78+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Release|x64.ActiveCfg = Release|Any CPU
79+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Release|x64.Build.0 = Release|Any CPU
80+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Release|x86.ActiveCfg = Release|Any CPU
81+
{C99C342C-FDAC-46DC-89B2-A06CB008348E}.Release|x86.Build.0 = Release|Any CPU
82+
EndGlobalSection
83+
GlobalSection(SolutionProperties) = preSolution
84+
HideSolutionNode = FALSE
85+
EndGlobalSection
86+
GlobalSection(NestedProjects) = preSolution
87+
{2AC73FBE-9E76-4702-B551-B5884383CC68} = {7183ECEC-9F44-48CE-BB97-AA2445170D5E}
88+
{C99C342C-FDAC-46DC-89B2-A06CB008348E} = {7183ECEC-9F44-48CE-BB97-AA2445170D5E}
89+
EndGlobalSection
90+
GlobalSection(ExtensibilityGlobals) = postSolution
91+
SolutionGuid = {91B9DE2A-8B79-4DC4-8235-216CD07F1CB2}
92+
EndGlobalSection
93+
EndGlobal
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Application
3+
x:Class="TodoApp.WinUI3.App"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:local="using:TodoApp.WinUI3">
7+
<Application.Resources>
8+
<ResourceDictionary>
9+
<ResourceDictionary.MergedDictionaries>
10+
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
11+
<!-- Other merged dictionaries here -->
12+
</ResourceDictionary.MergedDictionaries>
13+
<!-- Other app resources here -->
14+
</ResourceDictionary>
15+
</Application.Resources>
16+
</Application>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
// See the LICENSE file in the project root for more information.
4+
5+
using CommunityToolkit.Mvvm.DependencyInjection;
6+
using Microsoft.Data.Sqlite;
7+
using Microsoft.EntityFrameworkCore;
8+
using Microsoft.Extensions.DependencyInjection;
9+
using Microsoft.UI.Xaml;
10+
using Microsoft.UI.Xaml.Controls;
11+
using System;
12+
using TodoApp.WinUI3.Database;
13+
using TodoApp.WinUI3.Services;
14+
using TodoApp.WinUI3.ViewModels;
15+
using TodoApp.WinUI3.Views;
16+
17+
namespace TodoApp.WinUI3;
18+
19+
public partial class App : Application, IDisposable
20+
{
21+
private Window m_window;
22+
private Frame m_frame;
23+
private readonly SqliteConnection dbConnection;
24+
25+
public App()
26+
{
27+
InitializeComponent();
28+
29+
this.dbConnection = new SqliteConnection("Data Source=:memory:");
30+
this.dbConnection.Open();
31+
32+
IServiceCollection services = new ServiceCollection()
33+
.AddSingleton<ITodoService, LocalTodoService>()
34+
.AddTransient<TodoListViewModel>()
35+
.AddDbContext<AppDbContext>(options => options.UseSqlite(this.dbConnection));
36+
37+
Ioc.Default.ConfigureServices(services.BuildServiceProvider());
38+
}
39+
40+
protected override void OnLaunched(LaunchActivatedEventArgs args)
41+
{
42+
this.m_window = new Window();
43+
this.m_frame = new Frame();
44+
this.m_window.Content = this.m_frame;
45+
this.m_window.Activate();
46+
_ = this.m_frame.Navigate(typeof(TodoListPage));
47+
}
48+
49+
#region IDisposable
50+
private bool hasDisposed;
51+
52+
protected virtual void Dispose(bool disposing)
53+
{
54+
if (!this.hasDisposed)
55+
{
56+
if (disposing)
57+
{
58+
this.dbConnection.Close();
59+
}
60+
61+
this.hasDisposed = true;
62+
}
63+
}
64+
65+
public void Dispose()
66+
{
67+
Dispose(disposing: true);
68+
GC.SuppressFinalize(this);
69+
}
70+
#endregion
71+
}
373 Bytes
Loading
432 Bytes
Loading
866 Bytes
Loading
5.25 KB
Loading
1.71 KB
Loading
637 Bytes
Loading
283 Bytes
Loading

0 commit comments

Comments
 (0)