-
Notifications
You must be signed in to change notification settings - Fork 778
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #853 from Caliburn-Micro/feature/WinUI
Initial implementation of WinUI with samples and features working
- Loading branch information
Showing
125 changed files
with
2,679 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<cal:CaliburnApplication | ||
x:Class="Features.WinUI3.App" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Features.WinUI3" | ||
xmlns:cal="using:Caliburn.Micro"> | ||
<Application.Resources> | ||
<ResourceDictionary > | ||
<ResourceDictionary.MergedDictionaries> | ||
<XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" /> | ||
<!-- Other merged dictionaries here --> | ||
<ResourceDictionary> | ||
<SolidColorBrush x:Key="BackgroundBrush" Color="#FF225378" /> | ||
</ResourceDictionary> | ||
</ResourceDictionary.MergedDictionaries> | ||
<!-- Other app resources here --> | ||
</ResourceDictionary> | ||
</Application.Resources> | ||
</cal:CaliburnApplication> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// Provides application-specific behavior to supplement the default Application class. | ||
/// </summary> | ||
public partial class App : CaliburnApplication | ||
{ | ||
private WinRTContainer container; | ||
|
||
/// <summary> | ||
/// 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(). | ||
/// </summary> | ||
public App() | ||
Check warning on line 28 in samples/features/Features.WinUI3/App.xaml.cs GitHub Actions / build
|
||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
protected override void Configure() | ||
{ | ||
container = new WinRTContainer(); | ||
container.RegisterWinRTServices(); | ||
|
||
container | ||
.PerRequest<MenuViewModel>() | ||
.PerRequest<BindingsViewModel>() | ||
.PerRequest<ActionsViewModel>() | ||
.PerRequest<CoroutineViewModel>() | ||
.PerRequest<ExecuteViewModel>() | ||
.PerRequest<EventAggregationViewModel>() | ||
.PerRequest<DesignTimeViewModel>() | ||
.PerRequest<ConductorViewModel>() | ||
.PerRequest<BubblingViewModel>() | ||
.PerRequest<NavigationSourceViewModel>() | ||
.PerRequest<NavigationTargetViewModel>(); | ||
} | ||
|
||
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<MenuView>(); | ||
DisplayRootNavigationView(); | ||
} | ||
|
||
protected override object GetInstance(Type service, string key) | ||
{ | ||
return container.GetInstance(service, key); | ||
} | ||
|
||
protected override IEnumerable<object> 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(); | ||
} | ||
|
||
} | ||
} |
Binary file added
BIN
+432 Bytes
samples/features/Features.WinUI3/Assets/LockScreenLogo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+1.71 KB
samples/features/Features.WinUI3/Assets/Square150x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+637 Bytes
samples/features/Features.WinUI3/Assets/Square44x44Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+283 Bytes
...tures/Features.WinUI3/Assets/Square44x44Logo.targetsize-24_altform-unplated.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+2.05 KB
samples/features/Features.WinUI3/Assets/Wide310x150Logo.scale-200.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net8.0-windows10.0.19041.0</TargetFramework> | ||
<TargetPlatformMinVersion>10.0.17763.0</TargetPlatformMinVersion> | ||
<RootNamespace>Features.WinUI3</RootNamespace> | ||
<ApplicationManifest>app.manifest</ApplicationManifest> | ||
<Platforms>x86;x64;ARM64</Platforms> | ||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64</RuntimeIdentifiers> | ||
<PublishProfile>win-$(Platform).pubxml</PublishProfile> | ||
<UseWinUI>true</UseWinUI> | ||
<DefineConstants>WinUI3</DefineConstants> | ||
<EnableMsixTooling>true</EnableMsixTooling> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Content Include="Assets\SplashScreen.scale-200.png" /> | ||
<Content Include="Assets\LockScreenLogo.scale-200.png" /> | ||
<Content Include="Assets\Square150x150Logo.scale-200.png" /> | ||
<Content Include="Assets\Square44x44Logo.scale-200.png" /> | ||
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" /> | ||
<Content Include="Assets\StoreLogo.png" /> | ||
<Content Include="Assets\Wide310x150Logo.scale-200.png" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Manifest Include="$(ApplicationManifest)" /> | ||
</ItemGroup> | ||
|
||
<!-- | ||
Defining the "Msix" ProjectCapability here allows the Single-project MSIX Packaging | ||
Tools extension to be activated for this project even if the Windows App SDK Nuget | ||
package has not yet been restored. | ||
--> | ||
<ItemGroup Condition="'$(DisableMsixProjectCapabilityAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'"> | ||
<ProjectCapability Include="Msix" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.26100.1742" /> | ||
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.6.241114003" /> | ||
<PackageReference Include="Microsoft.Xaml.Behaviors.WinUI.Managed" Version="2.0.9" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Reference Include="Caliburn.Micro.Core"> | ||
<HintPath>..\..\..\bin\Caliburn.Micro.WinUI3\release\net8.0-windows10.0.19041.0\Caliburn.Micro.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Caliburn.Micro.Platform.Core"> | ||
<HintPath>..\..\..\bin\Caliburn.Micro.WinUI3\release\net8.0-windows10.0.19041.0\Caliburn.Micro.Platform.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Caliburn.Micro.WinUI3"> | ||
<HintPath>..\..\..\bin\Caliburn.Micro.WinUI3\release\net8.0-windows10.0.19041.0\Caliburn.Micro.WinUI3.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<Import Project="..\Features.CrossPlatform.Shared\Features.CrossPlatform.Shared.projitems" Label="Shared" /> | ||
|
||
<!-- | ||
Defining the "HasPackageAndPublishMenuAddedByProject" property here allows the Solution | ||
Explorer "Package and Publish" context menu entry to be enabled for this project even if | ||
the Windows App SDK Nuget package has not yet been restored. | ||
--> | ||
<PropertyGroup Condition="'$(DisableHasPackageAndPublishMenuAddedByProject)'!='true' and '$(EnableMsixTooling)'=='true'"> | ||
<HasPackageAndPublishMenu>true</HasPackageAndPublishMenu> | ||
</PropertyGroup> | ||
|
||
<!-- Publish Properties --> | ||
<PropertyGroup> | ||
<PublishReadyToRun Condition="'$(Configuration)' == 'Debug'">False</PublishReadyToRun> | ||
<PublishReadyToRun Condition="'$(Configuration)' != 'Debug'">True</PublishReadyToRun> | ||
<PublishTrimmed Condition="'$(Configuration)' == 'Debug'">False</PublishTrimmed> | ||
<PublishTrimmed Condition="'$(Configuration)' != 'Debug'">True</PublishTrimmed> | ||
</PropertyGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Window | ||
x:Class="Features.WinUI3.MainWindow" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:Features.WinUI3" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
Title="Features.WinUI3"> | ||
|
||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center"> | ||
<Button x:Name="myButton" Click="myButton_Click">Click Me</Button> | ||
</StackPanel> | ||
</Window> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
{ | ||
/// <summary> | ||
/// An empty window that can be used on its own or navigated to within a Frame. | ||
/// </summary> | ||
public sealed partial class MainWindow : Window | ||
{ | ||
public MainWindow() | ||
{ | ||
this.InitializeComponent(); | ||
} | ||
|
||
private void myButton_Click(object sender, RoutedEventArgs e) | ||
{ | ||
myButton.Content = "Clicked"; | ||
} | ||
} | ||
} |
Oops, something went wrong.