diff --git a/.github/workflows/dotnet.yml b/.github/workflows/dotnet.yml index 37b66d726..df5dbc32d 100644 --- a/.github/workflows/dotnet.yml +++ b/.github/workflows/dotnet.yml @@ -74,11 +74,11 @@ jobs: run: msbuild ${{env.caliburn_features}} -t:restore - name: Build feature features - run: msbuild ${{env.caliburn_features}} /t:Build /p:Configuration=${{env.build_configuration}} + run: msbuild ${{env.caliburn_features}} /t:Build /p:Configuration=Debug - name: Pack Nuget run: msbuild ${{env.caliburn_sln}} /t:package /p:Configuration=${{env.build_configuration}} - name: publish Nuget Packages to GitHub run: dotnet nuget push ${{env.nuget_upload}} --source ${{env.package_feed}} --api-key ${{secrets.PUBLISH_NUGET_PACKAGE}} --skip-duplicate - if: github.event_name != 'pull_request' \ No newline at end of file + if: github.event_name != 'pull_request' diff --git a/README.md b/README.md index 96f69edcd..40b1fb725 100644 --- a/README.md +++ b/README.md @@ -8,20 +8,20 @@ MyGet | [![MyGet Package](https://img.shields.io/myget/caliburn-micro-builds/v/c 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) GitHub Action | ![example workflow](https://github.com/Caliburn-Micro/Caliburn.Micro/actions/workflows/dotnet.yml/badge.svg) -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. +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. ## Packages are available on Nuget -- [Caliburn.Micro.Core](https://www.nuget.org/packages/Caliburn.Micro.Core/) - The Portable Class Library (PCL) portion of Caliburn.Micro. +- [Caliburn.Micro.Core](https://www.nuget.org/packages/Caliburn.Micro.Core/) - The Standard Class Library portion of Caliburn.Micro. - [Caliburn.Micro](https://www.nuget.org/packages/Caliburn.Micro/) - The platform-specific adapters for Caliburn.Micro. - [Caliburn.Micro.Xamarin.Forms](https://www.nuget.org/packages/Caliburn.Micro.Xamarin.Forms/) - Support to Caliburn.Micro in Xamarin.Forms. ## Packages are available on Github -- [Caliburn.Micro.Core](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Core) - The Portable Class Library (PCL) portion of Caliburn.Micro. +- [Caliburn.Micro.Core](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Core) - The Standard Class Library portion of Caliburn.Micro. - [Caliburn.Micro](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro) - The platform-specific adapters for Caliburn.Micro. - [Caliburn.Micro.Xamarin.Forms](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Xamarin.Forms) - Support to Caliburn.Micro for Xamarin.Forms. - [Caliburn.Micro.Maui](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Maui) - Support to Caliburn.Micro for dotnet Maui - [Caliburn.Micro.Avalonia](https://github.com/Caliburn-Micro/Caliburn.Micro/pkgs/nuget/Caliburn.Micro.Avalonia) - Support To Caliburn.Micro for Avalonia UI -- [Caliburn.Micro.WinUI]() - Support to Caliburn.Micro for WinUI (WinApp Sdk) Coming Soon +- [Caliburn.Micro.WinUI]() - Support to Caliburn.Micro for WinUI (WinApp Sdk) ## Questions - For non bug related questions see [Stack Overflow](https://stackoverflow.com/questions/tagged/caliburn.micro) diff --git a/samples/features/Features.Avalonia/Features.Avalonia.csproj b/samples/features/Features.Avalonia/Features.Avalonia.csproj index a7fdbd8c3..aecc7470b 100644 --- a/samples/features/Features.Avalonia/Features.Avalonia.csproj +++ b/samples/features/Features.Avalonia/Features.Avalonia.csproj @@ -17,18 +17,18 @@ - - - + + + - - - + + + - + diff --git a/samples/features/Features.CrossPlatform.Shared/Results/MessageDialogResult.cs b/samples/features/Features.CrossPlatform.Shared/Results/MessageDialogResult.cs index 0185223b4..8dece11b3 100644 --- a/samples/features/Features.CrossPlatform.Shared/Results/MessageDialogResult.cs +++ b/samples/features/Features.CrossPlatform.Shared/Results/MessageDialogResult.cs @@ -1,4 +1,5 @@ using System; +using System.Runtime.InteropServices; using Caliburn.Micro; #if XAMARINFORMS using Xamarin.Forms; @@ -51,6 +52,22 @@ public override async void Execute(CoroutineExecutionContext context) await dialog.ShowAsync(); OnCompleted(); } +#elif WinUI3 + public override async void Execute(CoroutineExecutionContext context) + { + var dialog = new MessageDialog(_content, _title); + + var hWnd = GetActiveWindow(); + + WinRT.Interop.InitializeWithWindow.Initialize(dialog, hWnd); + + await dialog.ShowAsync(); + + OnCompleted(); + } + + [DllImport("user32.dll")] + private static extern IntPtr GetActiveWindow(); #else public override async void Execute(CoroutineExecutionContext context) { diff --git a/samples/features/Features.CrossPlatform.Shared/Results/VisualStateResult.cs b/samples/features/Features.CrossPlatform.Shared/Results/VisualStateResult.cs index 846992480..2719995f3 100644 --- a/samples/features/Features.CrossPlatform.Shared/Results/VisualStateResult.cs +++ b/samples/features/Features.CrossPlatform.Shared/Results/VisualStateResult.cs @@ -5,6 +5,9 @@ #if SILVERLIGHT || WPF using System.Windows; using System.Windows.Controls; +#elif WinUI3 +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; #elif AVALONIA using Avalonia.Controls; #else diff --git a/samples/features/Features.UWP/Features.UWP.csproj b/samples/features/Features.UWP/Features.UWP.csproj index 12189c100..03958177f 100644 --- a/samples/features/Features.UWP/Features.UWP.csproj +++ b/samples/features/Features.UWP/Features.UWP.csproj @@ -11,7 +11,7 @@ Features.CrossPlatform en-US UAP - 10.0.20348.0 + 10.0.19041.0 10.0.19041.0 14 512 @@ -272,4 +272,4 @@ --> - \ No newline at end of file + diff --git a/samples/features/Features.WinUI3/App.xaml b/samples/features/Features.WinUI3/App.xaml new file mode 100644 index 000000000..b983256da --- /dev/null +++ b/samples/features/Features.WinUI3/App.xaml @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + diff --git a/samples/features/Features.WinUI3/App.xaml.cs b/samples/features/Features.WinUI3/App.xaml.cs new file mode 100644 index 000000000..1515821f4 --- /dev/null +++ b/samples/features/Features.WinUI3/App.xaml.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using Caliburn.Micro; +using Features.CrossPlatform.ViewModels; +using Features.CrossPlatform.Views; +using Features.WinUI3.Views; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Windows.ApplicationModel.Activation; +using Windows.UI.Popups; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace Features.WinUI3 +{ + /// + /// Provides application-specific behavior to supplement the default Application class. + /// + public partial class App : CaliburnApplication + { + private WinRTContainer container; + + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + } + + protected override void Configure() + { + container = new WinRTContainer(); + container.RegisterWinRTServices(); + + container + .PerRequest() + .PerRequest() + .PerRequest() + .PerRequest() + .PerRequest() + .PerRequest() + .PerRequest() + .PerRequest() + .PerRequest() + .PerRequest() + .PerRequest(); + } + + protected override void PrepareViewFirst(Frame rootFrame) + { + var navigationService = container.RegisterNavigationService(rootFrame); + } + + protected override void OnLaunched(Microsoft.UI.Xaml.LaunchActivatedEventArgs args) + { + if (args.UWPLaunchActivatedEventArgs.PreviousExecutionState == ApplicationExecutionState.Running) + return; + + //DisplayRootView(); + DisplayRootNavigationView(); + } + + protected override object GetInstance(Type service, string key) + { + return container.GetInstance(service, key); + } + + protected override IEnumerable GetAllInstances(Type service) + { + return container.GetAllInstances(service); + } + + protected override void BuildUp(object instance) + { + container.BuildUp(instance); + } + + protected override async void OnUnhandledException(object sender, Microsoft.UI.Xaml.UnhandledExceptionEventArgs e) + { + e.Handled = true; + + var dialog = new MessageDialog(e.Message, "An error has occurred"); + + await dialog.ShowAsync(); + } + + public void GoBack() + { + RootFrame.GoBack(); + } + + public void DisplayRootNavigationView() + { + Initialize(); + + InitializeWindow(); + PrepareViewFirst(); + + + RootFrame.Navigate(typeof(MenuView), null); + + var root = new RootView(RootFrame); + + // Seems stupid but observed weird behaviour when resetting the Content + Window.Content = root; + + Window.Activate(); + } + + } +} diff --git a/samples/features/Features.WinUI3/Assets/LockScreenLogo.scale-200.png b/samples/features/Features.WinUI3/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 000000000..7440f0d4b Binary files /dev/null and b/samples/features/Features.WinUI3/Assets/LockScreenLogo.scale-200.png differ diff --git a/samples/features/Features.WinUI3/Assets/SplashScreen.scale-200.png b/samples/features/Features.WinUI3/Assets/SplashScreen.scale-200.png new file mode 100644 index 000000000..32f486a86 Binary files /dev/null and b/samples/features/Features.WinUI3/Assets/SplashScreen.scale-200.png differ diff --git a/samples/features/Features.WinUI3/Assets/Square150x150Logo.scale-200.png b/samples/features/Features.WinUI3/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 000000000..53ee3777e Binary files /dev/null and b/samples/features/Features.WinUI3/Assets/Square150x150Logo.scale-200.png differ diff --git a/samples/features/Features.WinUI3/Assets/Square44x44Logo.scale-200.png b/samples/features/Features.WinUI3/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 000000000..f713bba67 Binary files /dev/null and b/samples/features/Features.WinUI3/Assets/Square44x44Logo.scale-200.png differ diff --git a/samples/features/Features.WinUI3/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/samples/features/Features.WinUI3/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 000000000..dc9f5bea0 Binary files /dev/null and b/samples/features/Features.WinUI3/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/samples/features/Features.WinUI3/Assets/StoreLogo.png b/samples/features/Features.WinUI3/Assets/StoreLogo.png new file mode 100644 index 000000000..a4586f26b Binary files /dev/null and b/samples/features/Features.WinUI3/Assets/StoreLogo.png differ diff --git a/samples/features/Features.WinUI3/Assets/Wide310x150Logo.scale-200.png b/samples/features/Features.WinUI3/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 000000000..8b4a5d0dd Binary files /dev/null and b/samples/features/Features.WinUI3/Assets/Wide310x150Logo.scale-200.png differ diff --git a/samples/features/Features.WinUI3/Features.WinUI3.csproj b/samples/features/Features.WinUI3/Features.WinUI3.csproj new file mode 100644 index 000000000..8ac846067 --- /dev/null +++ b/samples/features/Features.WinUI3/Features.WinUI3.csproj @@ -0,0 +1,73 @@ + + + WinExe + net8.0-windows10.0.19041.0 + 10.0.17763.0 + Features.WinUI3 + app.manifest + x86;x64;ARM64 + win-x86;win-x64;win-arm64 + win-$(Platform).pubxml + true + WinUI3 + true + enable + + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\..\..\bin\Caliburn.Micro.WinUI3\release\net8.0-windows10.0.19041.0\Caliburn.Micro.Core.dll + + + ..\..\..\bin\Caliburn.Micro.WinUI3\release\net8.0-windows10.0.19041.0\Caliburn.Micro.Platform.Core.dll + + + ..\..\..\bin\Caliburn.Micro.WinUI3\release\net8.0-windows10.0.19041.0\Caliburn.Micro.WinUI3.dll + + + + + + + true + + + + + False + True + False + True + + \ No newline at end of file diff --git a/samples/features/Features.WinUI3/MainWindow.xaml b/samples/features/Features.WinUI3/MainWindow.xaml new file mode 100644 index 000000000..67a814345 --- /dev/null +++ b/samples/features/Features.WinUI3/MainWindow.xaml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/samples/features/Features.WinUI3/MainWindow.xaml.cs b/samples/features/Features.WinUI3/MainWindow.xaml.cs new file mode 100644 index 000000000..a0d98463f --- /dev/null +++ b/samples/features/Features.WinUI3/MainWindow.xaml.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices.WindowsRuntime; +using Microsoft.UI.Xaml; +using Microsoft.UI.Xaml.Controls; +using Microsoft.UI.Xaml.Controls.Primitives; +using Microsoft.UI.Xaml.Data; +using Microsoft.UI.Xaml.Input; +using Microsoft.UI.Xaml.Media; +using Microsoft.UI.Xaml.Navigation; +using Windows.Foundation; +using Windows.Foundation.Collections; + +// To learn more about WinUI, the WinUI project structure, +// and more about our project templates, see: http://aka.ms/winui-project-info. + +namespace Features.WinUI3 +{ + /// + /// An empty window that can be used on its own or navigated to within a Frame. + /// + public sealed partial class MainWindow : Window + { + public MainWindow() + { + this.InitializeComponent(); + } + + private void myButton_Click(object sender, RoutedEventArgs e) + { + myButton.Content = "Clicked"; + } + } +} diff --git a/samples/features/Features.WinUI3/Package.appxmanifest b/samples/features/Features.WinUI3/Package.appxmanifest new file mode 100644 index 000000000..567c95d01 --- /dev/null +++ b/samples/features/Features.WinUI3/Package.appxmanifest @@ -0,0 +1,51 @@ + + + + + + + + + + Features.WinUI3 + vb2ae + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/features/Features.WinUI3/Views/ActionsView.xaml b/samples/features/Features.WinUI3/Views/ActionsView.xaml new file mode 100644 index 000000000..dbc9139bd --- /dev/null +++ b/samples/features/Features.WinUI3/Views/ActionsView.xaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + +