diff --git a/Avalonia.slnx b/Avalonia.slnx index 80b4042e7a..dba476ed4a 100644 --- a/Avalonia.slnx +++ b/Avalonia.slnx @@ -65,6 +65,10 @@ + + + + @@ -84,6 +88,10 @@ + + + + @@ -178,6 +186,7 @@ + diff --git a/Directory.Packages.props b/Directory.Packages.props index f4e677d631..cac3db9cc9 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -31,6 +31,8 @@ + + diff --git a/build/TargetFrameworks.props b/build/TargetFrameworks.props index 96541e7ecf..a380009e23 100644 --- a/build/TargetFrameworks.props +++ b/build/TargetFrameworks.props @@ -8,6 +8,7 @@ $(AvsCurrentTargetFramework)-ios26.0 $(AvsCurrentTargetFramework)-tvos26.0 $(AvsCurrentTargetFramework)-browser + $(AvsCurrentTargetFramework)-windows10.0.19041.0 net8.0 diff --git a/dirs.proj b/dirs.proj index 20df84439e..43c2518f78 100644 --- a/dirs.proj +++ b/dirs.proj @@ -14,12 +14,18 @@ + + + + + + diff --git a/samples/ControlGallery.WinUI/App.xaml b/samples/ControlGallery.WinUI/App.xaml new file mode 100644 index 0000000000..88b20eca37 --- /dev/null +++ b/samples/ControlGallery.WinUI/App.xaml @@ -0,0 +1,16 @@ + + + + + + + + + + + + diff --git a/samples/ControlGallery.WinUI/App.xaml.cs b/samples/ControlGallery.WinUI/App.xaml.cs new file mode 100644 index 0000000000..5d26d06383 --- /dev/null +++ b/samples/ControlGallery.WinUI/App.xaml.cs @@ -0,0 +1,40 @@ +using global::Avalonia; +using global::Avalonia.Controls; +using global::Avalonia.Controls.ApplicationLifetimes; +using global::Avalonia.Skia; +using global::Avalonia.Win32; +using WinUIApplication = Microsoft.UI.Xaml.Application; +using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs; +using Window = Microsoft.UI.Xaml.Window; + +namespace ControlGallery.WinUI +{ + public partial class App : WinUIApplication + { + private Window? _window; + + internal static SingleViewLifetime Lifetime { get; } = new(); + + public App() + { + InitializeComponent(); + } + + protected override void OnLaunched(LaunchActivatedEventArgs args) + { + AppBuilder.Configure() + .UseWin32() + .UseSkia() + .UseHarfBuzz() + .SetupWithLifetime(Lifetime); + + _window = new MainWindow(); + _window.Activate(); + } + } + + internal sealed class SingleViewLifetime : ISingleViewApplicationLifetime + { + public Control? MainView { get; set; } + } +} diff --git a/samples/ControlGallery.WinUI/Assets/LockScreenLogo.scale-200.png b/samples/ControlGallery.WinUI/Assets/LockScreenLogo.scale-200.png new file mode 100644 index 0000000000..7440f0d4bf Binary files /dev/null and b/samples/ControlGallery.WinUI/Assets/LockScreenLogo.scale-200.png differ diff --git a/samples/ControlGallery.WinUI/Assets/SplashScreen.scale-200.png b/samples/ControlGallery.WinUI/Assets/SplashScreen.scale-200.png new file mode 100644 index 0000000000..32f486a867 Binary files /dev/null and b/samples/ControlGallery.WinUI/Assets/SplashScreen.scale-200.png differ diff --git a/samples/ControlGallery.WinUI/Assets/Square150x150Logo.scale-200.png b/samples/ControlGallery.WinUI/Assets/Square150x150Logo.scale-200.png new file mode 100644 index 0000000000..53ee3777ea Binary files /dev/null and b/samples/ControlGallery.WinUI/Assets/Square150x150Logo.scale-200.png differ diff --git a/samples/ControlGallery.WinUI/Assets/Square44x44Logo.scale-200.png b/samples/ControlGallery.WinUI/Assets/Square44x44Logo.scale-200.png new file mode 100644 index 0000000000..f713bba67f Binary files /dev/null and b/samples/ControlGallery.WinUI/Assets/Square44x44Logo.scale-200.png differ diff --git a/samples/ControlGallery.WinUI/Assets/Square44x44Logo.targetsize-24_altform-unplated.png b/samples/ControlGallery.WinUI/Assets/Square44x44Logo.targetsize-24_altform-unplated.png new file mode 100644 index 0000000000..dc9f5bea0c Binary files /dev/null and b/samples/ControlGallery.WinUI/Assets/Square44x44Logo.targetsize-24_altform-unplated.png differ diff --git a/samples/ControlGallery.WinUI/Assets/StoreLogo.png b/samples/ControlGallery.WinUI/Assets/StoreLogo.png new file mode 100644 index 0000000000..a4586f26bd Binary files /dev/null and b/samples/ControlGallery.WinUI/Assets/StoreLogo.png differ diff --git a/samples/ControlGallery.WinUI/Assets/Wide310x150Logo.scale-200.png b/samples/ControlGallery.WinUI/Assets/Wide310x150Logo.scale-200.png new file mode 100644 index 0000000000..8b4a5d0dd5 Binary files /dev/null and b/samples/ControlGallery.WinUI/Assets/Wide310x150Logo.scale-200.png differ diff --git a/samples/ControlGallery.WinUI/ControlGallery.WinUI.csproj b/samples/ControlGallery.WinUI/ControlGallery.WinUI.csproj new file mode 100644 index 0000000000..4b3d246aaf --- /dev/null +++ b/samples/ControlGallery.WinUI/ControlGallery.WinUI.csproj @@ -0,0 +1,67 @@ + + + WinExe + $(AvsCurrentWinUITargetFramework) + 10.0.17763.0 + ControlGallery.WinUI + app.manifest + x86;x64;ARM64 + win-x86;win-x64;win-arm64 + win-$(Platform).pubxml + true + false + true + enable + true + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + + + + + False + True + False + True + + \ No newline at end of file diff --git a/samples/ControlGallery.WinUI/MainWindow.xaml b/samples/ControlGallery.WinUI/MainWindow.xaml new file mode 100644 index 0000000000..9595ef8253 --- /dev/null +++ b/samples/ControlGallery.WinUI/MainWindow.xaml @@ -0,0 +1,15 @@ + + + + + + + diff --git a/samples/ControlGallery.WinUI/MainWindow.xaml.cs b/samples/ControlGallery.WinUI/MainWindow.xaml.cs new file mode 100644 index 0000000000..7f9b40b82e --- /dev/null +++ b/samples/ControlGallery.WinUI/MainWindow.xaml.cs @@ -0,0 +1,11 @@ +namespace ControlGallery.WinUI +{ + public sealed partial class MainWindow : Microsoft.UI.Xaml.Window + { + public MainWindow() + { + InitializeComponent(); + AvaloniaPanel.Content = App.Lifetime.MainView; + } + } +} diff --git a/samples/ControlGallery.WinUI/Package.appxmanifest b/samples/ControlGallery.WinUI/Package.appxmanifest new file mode 100644 index 0000000000..fcd91fc1ac --- /dev/null +++ b/samples/ControlGallery.WinUI/Package.appxmanifest @@ -0,0 +1,51 @@ + + + + + + + + + + ControlGallery.WinUI + drasticactions + Assets\StoreLogo.png + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/ControlGallery.WinUI/Properties/launchSettings.json b/samples/ControlGallery.WinUI/Properties/launchSettings.json new file mode 100644 index 0000000000..ddb3c41a5a --- /dev/null +++ b/samples/ControlGallery.WinUI/Properties/launchSettings.json @@ -0,0 +1,10 @@ +{ + "profiles": { + "ControlGallery.WinUI (Package)": { + "commandName": "MsixPackage" + }, + "ControlGallery.WinUI (Unpackaged)": { + "commandName": "Project" + } + } +} \ No newline at end of file diff --git a/samples/ControlGallery.WinUI/app.manifest b/samples/ControlGallery.WinUI/app.manifest new file mode 100644 index 0000000000..e6d75d93fc --- /dev/null +++ b/samples/ControlGallery.WinUI/app.manifest @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + PerMonitorV2 + + + \ No newline at end of file diff --git a/samples/WinUIEmbedSample/App.xaml b/samples/WinUIEmbedSample/App.xaml new file mode 100644 index 0000000000..0bfa0c7b64 --- /dev/null +++ b/samples/WinUIEmbedSample/App.xaml @@ -0,0 +1,14 @@ + + + + + + + + + + diff --git a/samples/WinUIEmbedSample/App.xaml.cs b/samples/WinUIEmbedSample/App.xaml.cs new file mode 100644 index 0000000000..6524572edd --- /dev/null +++ b/samples/WinUIEmbedSample/App.xaml.cs @@ -0,0 +1,40 @@ +using global::Avalonia; +using global::Avalonia.Controls; +using global::Avalonia.Controls.ApplicationLifetimes; +using global::Avalonia.Skia; +using global::Avalonia.Win32; +using WinUIApplication = Microsoft.UI.Xaml.Application; +using LaunchActivatedEventArgs = Microsoft.UI.Xaml.LaunchActivatedEventArgs; +using Window = Microsoft.UI.Xaml.Window; + +namespace WinUIEmbedSample +{ + public partial class App : WinUIApplication + { + private Window? _window; + + internal static SingleViewLifetime Lifetime { get; } = new(); + + public App() + { + InitializeComponent(); + } + + protected override void OnLaunched(LaunchActivatedEventArgs args) + { + AppBuilder.Configure() + .UseWin32() + .UseSkia() + .UseHarfBuzz() + .SetupWithLifetime(Lifetime); + + _window = new MainWindow(); + _window.Activate(); + } + } + + internal sealed class SingleViewLifetime : ISingleViewApplicationLifetime + { + public Control? MainView { get; set; } + } +} diff --git a/samples/WinUIEmbedSample/AvaloniaApp.axaml b/samples/WinUIEmbedSample/AvaloniaApp.axaml new file mode 100644 index 0000000000..03c11e5146 --- /dev/null +++ b/samples/WinUIEmbedSample/AvaloniaApp.axaml @@ -0,0 +1,7 @@ + + + + + diff --git a/samples/WinUIEmbedSample/AvaloniaApp.axaml.cs b/samples/WinUIEmbedSample/AvaloniaApp.axaml.cs new file mode 100644 index 0000000000..854a7bd186 --- /dev/null +++ b/samples/WinUIEmbedSample/AvaloniaApp.axaml.cs @@ -0,0 +1,13 @@ +using global::Avalonia; +using global::Avalonia.Markup.Xaml; +using AvApplication = global::Avalonia.Application; + +namespace WinUIEmbedSample; + +public partial class AvaloniaApp : AvApplication +{ + public override void Initialize() + { + AvaloniaXamlLoader.Load(this); + } +} diff --git a/samples/WinUIEmbedSample/EmbeddedView.axaml b/samples/WinUIEmbedSample/EmbeddedView.axaml new file mode 100644 index 0000000000..9cfbd4cb1b --- /dev/null +++ b/samples/WinUIEmbedSample/EmbeddedView.axaml @@ -0,0 +1,228 @@ + + + + + + +