Skip to content

Commit d644b15

Browse files
authored
Merge pull request #853 from Caliburn-Micro/feature/WinUI
Initial implementation of WinUI with samples and features working
2 parents ee84233 + 5b49477 commit d644b15

File tree

125 files changed

+2679
-203
lines changed

Some content is hidden

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

125 files changed

+2679
-203
lines changed

.github/workflows/dotnet.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,11 @@ jobs:
7474
run: msbuild ${{env.caliburn_features}} -t:restore
7575

7676
- name: Build feature features
77-
run: msbuild ${{env.caliburn_features}} /t:Build /p:Configuration=${{env.build_configuration}}
77+
run: msbuild ${{env.caliburn_features}} /t:Build /p:Configuration=Debug
7878

7979
- name: Pack Nuget
8080
run: msbuild ${{env.caliburn_sln}} /t:package /p:Configuration=${{env.build_configuration}}
8181

8282
- name: publish Nuget Packages to GitHub
8383
run: dotnet nuget push ${{env.nuget_upload}} --source ${{env.package_feed}} --api-key ${{secrets.PUBLISH_NUGET_PACKAGE}} --skip-duplicate
84-
if: github.event_name != 'pull_request'
84+
if: github.event_name != 'pull_request'

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ MyGet | [![MyGet Package](https://img.shields.io/myget/caliburn-micro-builds/v/c
88
NuGet | [![NuGet Package](https://img.shields.io/nuget/v/Caliburn.Micro.svg?logo=nuget&logoColor=white&&style=for-the-badge&colorB=green)](https://www.nuget.org/packages/Caliburn.Micro)
99
GitHub Action | ![example workflow](https://github.com/Caliburn-Micro/Caliburn.Micro/actions/workflows/dotnet.yml/badge.svg)
1010

11-
Caliburn.Micro is a small, yet powerful framework, designed for building applications across all XAML platforms. With strong support for MVVM and other proven UI patterns, Caliburn.Micro will enable you to build your solution quickly, without the need to sacrifice code quality or testability.
11+
Caliburn.Micro is a small, yet powerful framework, designed for building applications across all XAML platforms. With strong support for MVVM and other proven UI patterns, Caliburn.Micro enables you to build your solution quickly without sacrificing code quality or testability.
1212

1313
## Packages are available on Nuget
14-
- [Caliburn.Micro.Core](https://www.nuget.org/packages/Caliburn.Micro.Core/) - The Portable Class Library (PCL) portion of Caliburn.Micro.
14+
- [Caliburn.Micro.Core](https://www.nuget.org/packages/Caliburn.Micro.Core/) - The Standard Class Library portion of Caliburn.Micro.
1515
- [Caliburn.Micro](https://www.nuget.org/packages/Caliburn.Micro/) - The platform-specific adapters for Caliburn.Micro.
1616
- [Caliburn.Micro.Xamarin.Forms](https://www.nuget.org/packages/Caliburn.Micro.Xamarin.Forms/) - Support to Caliburn.Micro in Xamarin.Forms.
1717

1818
## Packages are available on Github
19-
- [Caliburn.Micro.Core](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Core) - The Portable Class Library (PCL) portion of Caliburn.Micro.
19+
- [Caliburn.Micro.Core](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Core) - The Standard Class Library portion of Caliburn.Micro.
2020
- [Caliburn.Micro](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro) - The platform-specific adapters for Caliburn.Micro.
2121
- [Caliburn.Micro.Xamarin.Forms](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Xamarin.Forms) - Support to Caliburn.Micro for Xamarin.Forms.
2222
- [Caliburn.Micro.Maui](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Maui) - Support to Caliburn.Micro for dotnet Maui
2323
- [Caliburn.Micro.Avalonia](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Avalonia) - Support To Caliburn.Micro for Avalonia UI
24-
- [Caliburn.Micro.WinUI]() - Support to Caliburn.Micro for WinUI (WinApp Sdk) Coming Soon
24+
- [Caliburn.Micro.WinUI]() - Support to Caliburn.Micro for WinUI (WinApp Sdk)
2525

2626
## Questions
2727
- For non bug related questions see [Stack Overflow](https://stackoverflow.com/questions/tagged/caliburn.micro)

samples/features/Features.Avalonia/Features.Avalonia.csproj

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717
<None Remove=".gitignore" />
1818
</ItemGroup>
1919
<ItemGroup>
20-
<PackageReference Include="Avalonia" Version="11.2.2" />
21-
<PackageReference Include="Avalonia.Desktop" Version="11.2.2" />
22-
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="11.2.2" />
20+
<PackageReference Include="Avalonia" Version="11.2.3" />
21+
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
22+
<PackageReference Include="Avalonia.Markup.Xaml.Loader" Version="11.2.3" />
2323

24-
<PackageReference Include="Avalonia.Themes.FLuent" Version="11.2.2" />
25-
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.2.0.1" />
26-
<PackageReference Include="Avalonia.Xaml.Interactivity" Version="11.2.0.1" />
24+
<PackageReference Include="Avalonia.Themes.FLuent" Version="11.2.3" />
25+
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="11.2.0.7" />
26+
<PackageReference Include="Avalonia.Xaml.Interactivity" Version="11.2.0.7" />
2727
<PackageReference Include="MessageBox.Avalonia" Version="3.2.0" />
2828
<PackageReference Include="System.Reactive" Version="6.0.1" />
2929
<PackageReference Include="XamlNameReferenceGenerator" Version="1.6.1" />
3030
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
31-
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.2" />
31+
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.3" />
3232
</ItemGroup>
3333
<ItemGroup>
3434
<Reference Include="Caliburn.Micro.Avalonia">

samples/features/Features.CrossPlatform.Shared/Results/MessageDialogResult.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Runtime.InteropServices;
23
using Caliburn.Micro;
34
#if XAMARINFORMS
45
using Xamarin.Forms;
@@ -51,6 +52,22 @@ public override async void Execute(CoroutineExecutionContext context)
5152
await dialog.ShowAsync();
5253
OnCompleted();
5354
}
55+
#elif WinUI3
56+
public override async void Execute(CoroutineExecutionContext context)
57+
{
58+
var dialog = new MessageDialog(_content, _title);
59+
60+
var hWnd = GetActiveWindow();
61+
62+
WinRT.Interop.InitializeWithWindow.Initialize(dialog, hWnd);
63+
64+
await dialog.ShowAsync();
65+
66+
OnCompleted();
67+
}
68+
69+
[DllImport("user32.dll")]
70+
private static extern IntPtr GetActiveWindow();
5471
#else
5572
public override async void Execute(CoroutineExecutionContext context)
5673
{

samples/features/Features.CrossPlatform.Shared/Results/VisualStateResult.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
#if SILVERLIGHT || WPF
66
using System.Windows;
77
using System.Windows.Controls;
8+
#elif WinUI3
9+
using Microsoft.UI.Xaml;
10+
using Microsoft.UI.Xaml.Controls;
811
#elif AVALONIA
912
using Avalonia.Controls;
1013
#else

samples/features/Features.UWP/Features.UWP.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<AssemblyName>Features.CrossPlatform</AssemblyName>
1212
<DefaultLanguage>en-US</DefaultLanguage>
1313
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
14-
<TargetPlatformVersion>10.0.20348.0</TargetPlatformVersion>
14+
<TargetPlatformVersion>10.0.19041.0</TargetPlatformVersion>
1515
<TargetPlatformMinVersion>10.0.19041.0</TargetPlatformMinVersion>
1616
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
1717
<FileAlignment>512</FileAlignment>
@@ -272,4 +272,4 @@
272272
<Target Name="AfterBuild">
273273
</Target>
274274
-->
275-
</Project>
275+
</Project>
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<cal:CaliburnApplication
3+
x:Class="Features.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:Features.WinUI3"
7+
xmlns:cal="using:Caliburn.Micro">
8+
<Application.Resources>
9+
<ResourceDictionary >
10+
<ResourceDictionary.MergedDictionaries>
11+
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
12+
<!-- Other merged dictionaries here -->
13+
<ResourceDictionary>
14+
<SolidColorBrush x:Key="BackgroundBrush" Color="#FF225378" />
15+
</ResourceDictionary>
16+
</ResourceDictionary.MergedDictionaries>
17+
<!-- Other app resources here -->
18+
</ResourceDictionary>
19+
</Application.Resources>
20+
</cal:CaliburnApplication>
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Caliburn.Micro;
4+
using Features.CrossPlatform.ViewModels;
5+
using Features.CrossPlatform.Views;
6+
using Features.WinUI3.Views;
7+
using Microsoft.UI.Xaml;
8+
using Microsoft.UI.Xaml.Controls;
9+
using Windows.ApplicationModel.Activation;
10+
using Windows.UI.Popups;
11+
12+
// To learn more about WinUI, the WinUI project structure,
13+
// and more about our project templates, see: http://aka.ms/winui-project-info.
14+
15+
namespace Features.WinUI3
16+
{
17+
/// <summary>
18+
/// Provides application-specific behavior to supplement the default Application class.
19+
/// </summary>
20+
public partial class App : CaliburnApplication
21+
{
22+
private WinRTContainer container;
23+
24+
/// <summary>
25+
/// Initializes the singleton application object. This is the first line of authored code
26+
/// executed, and as such is the logical equivalent of main() or WinMain().
27+
/// </summary>
28+
public App()
29+
{
30+
this.InitializeComponent();
31+
}
32+
33+
protected override void Configure()
34+
{
35+
container = new WinRTContainer();
36+
container.RegisterWinRTServices();
37+
38+
container
39+
.PerRequest<MenuViewModel>()
40+
.PerRequest<BindingsViewModel>()
41+
.PerRequest<ActionsViewModel>()
42+
.PerRequest<CoroutineViewModel>()
43+
.PerRequest<ExecuteViewModel>()
44+
.PerRequest<EventAggregationViewModel>()
45+
.PerRequest<DesignTimeViewModel>()
46+
.PerRequest<ConductorViewModel>()
47+
.PerRequest<BubblingViewModel>()
48+
.PerRequest<NavigationSourceViewModel>()
49+
.PerRequest<NavigationTargetViewModel>();
50+
}
51+
52+
protected override void PrepareViewFirst(Frame rootFrame)
53+
{
54+
var navigationService = container.RegisterNavigationService(rootFrame);
55+
}
56+
57+
protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args)
58+
{
59+
if (args.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Running)
60+
return;
61+
62+
//DisplayRootView<MenuView>();
63+
DisplayRootNavigationView();
64+
}
65+
66+
protected override object GetInstance(Type service, string key)
67+
{
68+
return container.GetInstance(service, key);
69+
}
70+
71+
protected override IEnumerable<object> GetAllInstances(Type service)
72+
{
73+
return container.GetAllInstances(service);
74+
}
75+
76+
protected override void BuildUp(object instance)
77+
{
78+
container.BuildUp(instance);
79+
}
80+
81+
protected override async void OnUnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e)
82+
{
83+
e.Handled = true;
84+
85+
var dialog = new MessageDialog(e.Message, "An error has occurred");
86+
87+
await dialog.ShowAsync();
88+
}
89+
90+
public void GoBack()
91+
{
92+
RootFrame.GoBack();
93+
}
94+
95+
public void DisplayRootNavigationView()
96+
{
97+
Initialize();
98+
99+
InitializeWindow();
100+
PrepareViewFirst();
101+
102+
103+
RootFrame.Navigate(typeof(MenuView), null);
104+
105+
var root = new RootView(RootFrame);
106+
107+
// Seems stupid but observed weird behaviour when resetting the Content
108+
Window.Content = root;
109+
110+
Window.Activate();
111+
}
112+
113+
}
114+
}
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>WinExe</OutputType>
4+
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework>
5+
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion>
6+
<RootNamespace>Features.WinUI3</RootNamespace>
7+
<ApplicationManifest>app.manifest</ApplicationManifest>
8+
<Platforms>x86;x64;ARM64</Platforms>
9+
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers>
10+
<PublishProfile>win-$(Platform).pubxml</PublishProfile>
11+
<UseWinUI>true</UseWinUI>
12+
<DefineConstants>WinUI3</DefineConstants>
13+
<EnableMsixTooling>true</EnableMsixTooling>
14+
<Nullable>enable</Nullable>
15+
</PropertyGroup>
16+
17+
<ItemGroup>
18+
<Content Include="Assets\SplashScreen.scale-200.png" />
19+
<Content Include="Assets\LockScreenLogo.scale-200.png" />
20+
<Content Include="Assets\Square150x150Logo.scale-200.png" />
21+
<Content Include="Assets\Square44x44Logo.scale-200.png" />
22+
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
23+
<Content Include="Assets\StoreLogo.png" />
24+
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
25+
</ItemGroup>
26+
27+
<ItemGroup>
28+
<Manifest Include="$(ApplicationManifest)" />
29+
</ItemGroup>
30+
31+
<!--
32+
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging
33+
Tools extension to be activated for this project even if the Windows App SDK Nuget
34+
package has not yet been restored.
35+
-->
36+
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
37+
<ProjectCapability Include="Msix" />
38+
</ItemGroup>
39+
<ItemGroup>
40+
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" />
41+
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.241114003" />
42+
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" />
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Reference Include="Caliburn.Micro.Core">
46+
<HintPath>..\..\..\bin\Caliburn.Micro.WinUI3\release\net8.0-windows10.0.19041.0\Caliburn.Micro.Core.dll</HintPath>
47+
</Reference>
48+
<Reference Include="Caliburn.Micro.Platform.Core">
49+
<HintPath>..\..\..\bin\Caliburn.Micro.WinUI3\release\net8.0-windows10.0.19041.0\Caliburn.Micro.Platform.Core.dll</HintPath>
50+
</Reference>
51+
<Reference Include="Caliburn.Micro.WinUI3">
52+
<HintPath>..\..\..\bin\Caliburn.Micro.WinUI3\release\net8.0-windows10.0.19041.0\Caliburn.Micro.WinUI3.dll</HintPath>
53+
</Reference>
54+
</ItemGroup>
55+
<Import Project="..\Features.CrossPlatform.Shared\Features.CrossPlatform.Shared.projitems" Label="Shared" />
56+
57+
<!--
58+
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution
59+
Explorer "Package and Publish" context menu entry to be enabled for this project even if
60+
the Windows App SDK Nuget package has not yet been restored.
61+
-->
62+
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'">
63+
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu>
64+
</PropertyGroup>
65+
66+
<!-- Publish Properties -->
67+
<PropertyGroup>
68+
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun>
69+
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun>
70+
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed>
71+
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed>
72+
</PropertyGroup>
73+
</Project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Window
3+
x:Class="Features.WinUI3.MainWindow"
4+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
5+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
6+
xmlns:local="using:Features.WinUI3"
7+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
8+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
9+
mc:Ignorable="d"
10+
Title="Features.WinUI3">
11+
12+
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center">
13+
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button>
14+
</StackPanel>
15+
</Window>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.IO;
4+
using System.Linq;
5+
using System.Runtime.InteropServices.WindowsRuntime;
6+
using Microsoft.UI.Xaml;
7+
using Microsoft.UI.Xaml.Controls;
8+
using Microsoft.UI.Xaml.Controls.Primitives;
9+
using Microsoft.UI.Xaml.Data;
10+
using Microsoft.UI.Xaml.Input;
11+
using Microsoft.UI.Xaml.Media;
12+
using Microsoft.UI.Xaml.Navigation;
13+
using Windows.Foundation;
14+
using Windows.Foundation.Collections;
15+
16+
// To learn more about WinUI, the WinUI project structure,
17+
// and more about our project templates, see: http://aka.ms/winui-project-info.
18+
19+
namespace Features.WinUI3
20+
{
21+
/// <summary>
22+
/// An empty window that can be used on its own or navigated to within a Frame.
23+
/// </summary>
24+
public sealed partial class MainWindow : Window
25+
{
26+
public MainWindow()
27+
{
28+
this.InitializeComponent();
29+
}
30+
31+
private void myButton_Click(object sender, RoutedEventArgs e)
32+
{
33+
myButton.Content = "Clicked";
34+
}
35+
}
36+
}

0 commit comments

Comments
 (0)