Skip to content

Commit

Permalink
Merge pull request #203 from AvaloniaCommunity/feature/v9.0.537.111x0
Browse files Browse the repository at this point in the history
Feature/v9.0.537.111x0
  • Loading branch information
DamianSuess authored Aug 24, 2024
2 parents 686771e + 33c22ab commit 30a4225
Show file tree
Hide file tree
Showing 21 changed files with 174 additions and 149 deletions.
7 changes: 7 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

Change log history for Prism.Avalonia

## v9.0.537.11130 (2024-08-24)

* Upgraded to Prism v9.0.537
* Upgraded to Avalonia v11.1.3
* More clear error message throwing
* Updated end-to-end samples

## v9.0.401.11110-pre (2024-08-03)

* Upgraded to Avalonia v11.1.1
Expand Down
22 changes: 11 additions & 11 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@
<!-- Prism -->
<ItemGroup>
<PackageVersion Include="Prism.Core" Version="9.0.537" />
<PackageVersion Include="Prism.Container.Abstractions" Version="9.0.84-pre" />
<PackageVersion Include="Prism.Container.DryIoc" Version="9.0.107" />
<PackageVersion Include="Prism.Container.Unity" Version="9.0.84-pre" />
<PackageVersion Include="Prism.Container.Abstractions" Version="9.0.107" />
<PackageVersion Include="Prism.Container.Unity" Version="9.0.107" />
</ItemGroup>
<!-- Avalonia -->
<ItemGroup>
<PackageVersion Include="Avalonia" Version="11.1.1" />
<PackageVersion Include="Avalonia.Desktop" Version="11.1.1" />
<PackageVersion Include="Avalonia.Diagnostics" Version="11.1.1" />
<PackageVersion Include="Avalonia.LinuxFramebuffer" Version="11.1.1" />
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="11.1.1" />
<PackageVersion Include="Avalonia.Themes.Simple" Version="11.1.1" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.1.1" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.1.1" />
<PackageVersion Include="Avalonia" Version="11.1.3" />
<PackageVersion Include="Avalonia.Desktop" Version="11.1.3" />
<PackageVersion Include="Avalonia.Diagnostics" Version="11.1.3" />
<PackageVersion Include="Avalonia.LinuxFramebuffer" Version="11.1.3" />
<PackageVersion Include="Avalonia.Markup.Xaml.Loader" Version="11.1.3" />
<PackageVersion Include="Avalonia.Themes.Simple" Version="11.1.3" />
<PackageVersion Include="Avalonia.Themes.Fluent" Version="11.1.3" />
<PackageVersion Include="Avalonia.Fonts.Inter" Version="11.1.3" />
</ItemGroup>
<!-- 3rd-Party -->
<ItemGroup>
Expand All @@ -39,4 +39,4 @@
<PackageVersion Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageVersion Include="Xunit.StaFact" Version="1.1.11" />
</ItemGroup>
</Project>
</Project>
216 changes: 100 additions & 116 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Prism.Avalonia

[Prism.Avalonia](https://github.com/AvaloniaCommunity/Prism.Avalonia) provides your cross-platform [Avalonia](https://avaloniaui.net/) apps with [Prism framework](https://github.com/PrismLibrary/Prism) support so you can **Navigate**, create **Dialog Windows** and **Notifications**, provide **Dependency Injection** and internal **Messaging** easier than before! You will need both packages installed to get started.
<center>

![Logo](https://raw.githubusercontent.com/AvaloniaCommunity/Prism.Avalonia/develop/images/Prism.Avalonia.png)
</center>

[Prism.Avalonia](https://github.com/AvaloniaCommunity/Prism.Avalonia) provides your cross-platform [Avalonia](https://avaloniaui.net/) apps with [Prism framework](https://github.com/PrismLibrary/Prism) support so you can **Navigate**, create **Dialog Windows** and **Notifications**, provide **Dependency Injection** and internal **Messaging** easier than before! You will need both packages installed to get started.

> **Announcement!**
>
> * **NEW:**_[Official Prism.Avalonia Templates arrived!](https://github.com/SuessLabs/Prism.Avalonia.Templates)_
> * _Prism.Avalonia v9.0.401-pre - **Available!**_
> * _Prism.Avalonia v9.0.537 - **Coming Soon!**_
> * _Support for Avalonia v11.1.x has arrived!_
> * Follow the [Upgrading to Prism v9.0.x-pre](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki/Upgrading-to-Prism-v9.0) guide for breaking changes
> * **NEW:** _[Official Prism.Avalonia Templates arrived!](https://github.com/SuessLabs/Prism.Avalonia.Templates)_
> * _Prism.Avalonia v9.0.537 - **Available!**_
> * Check out the [Upgrading to Prism v9.0](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki/Upgrading-to-Prism-v9.0) guide to avoid breaking changes in your apps
**For more samples outside of this repo, check out:**

Expand All @@ -17,11 +20,11 @@
* _If you have samples, let us know and we'll feature them!_

<!-- ![Sample Outlookish](logo/Sample-Outlookish.png) -->
![Sample Outlookish](https://raw.githubusercontent.com/AvaloniaCommunity/Prism.Avalonia/stable/v8.1.97.11xx/logo/Sample-Outlookish.png)
![Sample Outlookish](https://raw.githubusercontent.com/AvaloniaCommunity/Prism.Avalonia/master/images/Sample-Outlookish.png)

With Prism.Avalonia's logic and development approach being **similar** to that of [Prism for WPF](https://github.com/PrismLibrary/Prism/), so you can get started right away! Keep in mind, they are **similar** and not 1-to-1. Check out our [Wiki](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki) and [Avalonia Outlookish](https://github.com/DamianSuess/Learn.PrismAvaloniaOutlookish) app for tips and tricks.

This project currently supports cross-platform Desktop applications (_Windows, Linux, Mac_). Support for Android, iOS, and web apps is still under evaluation; and is not 100%. Feel free to contribute to improve this. 😃
This project currently supports cross-platform Desktop applications (_Windows, Linux, Mac_). Support for Android, iOS, and web apps is still under evaluation; and is not 100%. Feel free to contribute and help us improve. 😃

## Package Releases

Expand All @@ -36,10 +39,11 @@ Just like _Prism.WPF or Prism.Maui_, your project must reference both the **Pris

Choose the NuGet package version that matches your Avalonia version.

Our [versioning schema](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki/Versioning-Schema) is based on the [SemVer](https://semver.org/) using the format `MAJOR.MINOR.PATCH.REVISION`. The `REVISION` segment indicates the Avalonia version support. For instance `v8.1.97.11073` equates to, Prism `v8.1.97`, Avalonia `v11.0.7`, _revision_ `3`.
Our [versioning schema](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki/Versioning-Schema) is based on the [SemVer](https://semver.org/) using the format `MAJOR.MINOR.PATCH.REVISION`. The `REVISION` segment indicates the Avalonia version support. For instance `v9.0.537.11234` equates to, Prism `v9.0.537`, Avalonia `v11.2.3`, _revision_ `4`.

| Prism | Avalonia | Prism.Avalonia NuGet Package
|-|-|-
| v9.0.537 | **11.1.3** | v9.0.537.11130 ([Core](https://www.nuget.org/packages/Prism.Avalonia/9.0.537.11130)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/9.0.537.11130))
| v9.0.401-pre | **11.1.1** | v9.0.401.11110-pre ([Core](https://www.nuget.org/packages/Prism.Avalonia/9.0.401.11110-pre)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/9.0.401.11110-pre))
| v9.0.401-pre | **11.0.7** | v9.0.401.11074-pre ([Core](https://www.nuget.org/packages/Prism.Avalonia/9.0.401.11074-pre)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/9.0.401.11074-pre))
| v9.0.271-pre | **11.0.7** | v9.0.271.11000-pre ([Core](https://www.nuget.org/packages/Prism.Avalonia/9.0.271.11000-pre)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/9.0.271.11000-pre))
Expand Down Expand Up @@ -67,140 +71,120 @@ Issues posted without a description may be closed immediately. Use the discussio
Add the Prism.Avalonia and its DryIoc packages to your project:

```powershell
# Latest Preview Release
Install-Package Prism.Avalonia -Version 9.0.401.11110-pre
Install-Package Prism.DryIoc.Avalonia -Version 9.0.401.11110-pre
# Avalonia v11.1 - Latest Release
Install-Package Prism.Avalonia -Version 9.0.537.11130
Install-Package Prism.DryIoc.Avalonia -Version 9.0.537.11130
# Avalonia v11 (GA)
# Legacy: Avalonia v11.0
Install-Package Prism.Avalonia -Version 8.1.97.11073
Install-Package Prism.DryIoc.Avalonia -Version 8.1.97.11073
# Avalonia v0.10.1021
# Legacy: Avalonia v0.10.1021
Install-Package Prism.Avalonia -Version 8.1.97.1021
Install-Package Prism.DryIoc.Avalonia -Version 8.1.97.1021
```

## How to use

### App.xaml.cs

```csharp
public class App : PrismApplication
{
public static bool IsSingleViewLifetime =>
Environment.GetCommandLineArgs()
.Any(a => a == "--fbdev" || a == "--drm");
### Program.cs

public static AppBuilder BuildAvaloniaApp() =>
AppBuilder
.Configure<App>()
.UsePlatformDetect();
The default Avalonia entrypoint `Program.cs` does not need to be modified. Below is provided as a sample.

public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
base.Initialize(); // <-- Required
}
```csharp
using System;
using Avalonia;

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// Register Services
containerRegistry.Register<IRestService, RestService>();
namespace SampleBaseApp;

// Views - Generic
containerRegistry.Register<MainWindow>();
internal sealed class Program
{
// Initialization code. Don't use any Avalonia, third-party APIs or any
// SynchronizationContext-reliant code before AppMain is called
[STAThread]
public static void Main(string[] args) => BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);

// Avalonia configuration, don't remove; also used by visual designer.
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
}

// Views - Region Navigation
containerRegistry.RegisterForNavigation<DashboardView, DashboardViewModel>();
containerRegistry.RegisterForNavigation<SettingsView, SettingsViewModel>();
containerRegistry.RegisterForNavigation<SidebarView, SidebarViewModel>();
}
```

protected override AvaloniaObject CreateShell()
{
if (IsSingleViewLifetime)
return Container.Resolve<MainControl>(); // For Linux Framebuffer or DRM
else
return Container.Resolve<MainWindow>();
}
### App.axaml

protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
// Register modules
moduleCatalog.AddModule<Module1.Module>();
moduleCatalog.AddModule<Module2.Module>();
moduleCatalog.AddModule<Module3.Module>();
}
```xml
<Application xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SampleBaseApp.App"
xmlns:local="using:SampleBaseApp"
RequestedThemeVariant="Default">
<!-- RequestedThemeVariant allows for the following types, "Default", "Dark", or "Light". -->

/// <summary>Called after <seealso cref="Initialize"/>.</summary>
protected override void OnInitialized()
{
// Register initial Views to Region.
var regionManager = Container.Resolve<IRegionManager>();
regionManager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(DashboardView));
regionManager.RegisterViewWithRegion(RegionNames.SidebarRegion, typeof(SidebarView));
}
}
<Application.Styles>
<FluentTheme />
</Application.Styles>
</Application>
```

### Program.cs
### App.axaml.cs

Your default Avalonia `Program.cs` file does not need to be modified. Below is provided as a sample.
> **Notice:**
>
> We do not need the `OnFrameworkInitializationCompleted()` method. However, you must include `base.Initialize();` in the `Initialize()` method to kick-start Prism.Avalonia.
>
> Also, in your `App.axaml` you no longer need to device the `<Design.DataContext>`. Prism takes care of this for you! (:
```csharp
public static class Program
using System;
using Avalonia;
using Avalonia.Markup.Xaml;
using Prism.DryIoc;
using Prism.Ioc;
using SampleBaseApp.Views;

namespace SampleBaseApp;

public partial class App : PrismApplication
{
public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure<App>()
.UsePlatformDetect()
.With(new X11PlatformOptions
{
EnableMultiTouch = true,
UseDBusMenu = true
})
.With(new Win32PlatformOptions())
.UseSkia()
.UseReactiveUI()
.UseManagedSystemDialogs();

static int Main(string[] args)
{
double GetScaling()
{
var idx = Array.IndexOf(args, "--scaling");
if (idx != 0 && args.Length > idx + 1 &&
double.TryParse(args[idx + 1], NumberStyles.Any, CultureInfo.InvariantCulture, out var scaling))
return scaling;
return 1;
}

var builder = BuildAvaloniaApp();
InitializeLogging();
if (args.Contains("--fbdev"))
{
SilenceConsole();
return builder.StartLinuxFbDev(args, scaling: GetScaling());
}
else if (args.Contains("--drm"))
{
SilenceConsole();
return builder.StartLinuxDrm(args, scaling: GetScaling());
}
else
return builder.StartWithClassicDesktopLifetime(args);
}
public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
base.Initialize(); // Required to initialize Prism.Avalonia - DO NOT REMOVE
}

static void SilenceConsole()
protected override AvaloniaObject CreateShell()
{
Console.WriteLine("CreateShell()");

return Container.Resolve<MainWindow>();
}

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// Add Services and ViewModel registrations here
Console.WriteLine("RegisterTypes()");

// Services
//// containerRegistry.RegisterSingleton<ISampleService, ISampleService>();
// Views - Region Navigation
//// containerRegistry.RegisterForNavigation<DashboardView, DashboardViewModel>();
// Dialogs
//// containerRegistry.RegisterDialog<MessageBoxView, MessageBoxViewModel>();
//// containerRegistry.RegisterDialogWindow<CustomDialogWindow>(nameof(CustomDialogWindow));
}

protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
new Thread(() =>
{
Console.CursorVisible = false;
while (true)
Console.ReadKey(true);
})
{ IsBackground = true }.Start();
// Register modules
//// moduleCatalog.AddModule<DummyModule.DummyModule1>();
}
}
```

## House Keeping
Expand Down
2 changes: 1 addition & 1 deletion build/Base.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project DefaultTargets="Build"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Version>9.0.537.11110</Version>
<Version>9.0.537.11130</Version>
<PackageProjectUrl>https://github.com/AvaloniaCommunity/Prism.Avalonia</PackageProjectUrl>
<Copyright>Copyright (c) 2024 Xeno Innovations, Inc.</Copyright>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
Expand Down
5 changes: 2 additions & 3 deletions build/Nuget.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageReleaseNotes>
* Upgraded to support Avalonia v11.1.1
* Upgraded to support Prism v9.0.401-pre
* Fixed ItemsControlRegionAdapter not attaching object due to previous binding (Avalonia v11.x)
* Upgraded to support Prism v9.0.537
* Upgraded to support Avalonia v11.1.3
</PackageReleaseNotes>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion build/SampleApp.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<Import Project="AvaloniaDependency.props" />

<ItemGroup>
<PackageReference Include="Avalonia" Version="11.1.1" />
<PackageReference Include="Avalonia" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" />
<PackageReference Include="Avalonia.Desktop" />
Expand Down
2 changes: 2 additions & 0 deletions e2e/BootstrapperShellSample/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public partial class MainWindow : Window
public MainWindow()
{
this.InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif
}
}
}
2 changes: 2 additions & 0 deletions e2e/ModulesSample/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ public MainWindow()
public MainWindow(IEventAggregator eventAggregator)
{
InitializeComponent();
#if DEBUG
this.AttachDevTools();
#endif

_logTextBox = this.FindControl<TextBox>("LogTextBox");
_itemsControl = this.FindControl<ListBox>("ItemsControl1");
Expand Down
Loading

0 comments on commit 30a4225

Please sign in to comment.