Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/avaloniacommunity/prism.avalonia

Prism Avalonia UI framework. Super charge your cross-platform apps with IoC, navigation, and more! Sponsored by Suess Labs. Prism is based on Microsoft patterns and practices.
https://github.com/avaloniacommunity/prism.avalonia

avalonia csharp dependency-injection dotnet dotnetcore mvvm net6 net7 net8 prism prismavalonia suesslabs xeno-innovations

Last synced: 4 days ago
JSON representation

Prism Avalonia UI framework. Super charge your cross-platform apps with IoC, navigation, and more! Sponsored by Suess Labs. Prism is based on Microsoft patterns and practices.

Awesome Lists containing this project

README

        

# Prism.Avalonia

> ## Announcement
>
> **Prism.Avalonia** is officially moving to [Prism Library](https://github.com/PrismLibrary/Prism)!

> _Follow the [PR](https://github.com/PrismLibrary/Prism/pull/3127) for more information._
>
> Until full integration, keep reaching out on this site.
>
> Thank you all for helping to mature and make this project into what it is today. I look forward to continuing efforts on Prism Avalonia as part of the official package.
>
> _See you over there for future releases_!
>
> `- Damian`
>

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

[Prism.Avalonia](https://github.com/AvaloniaCommunity/Prism.Avalonia) provides your cross-platform [Avalonia](https://avaloniaui.net/) apps with [Prism library](https://github.com/PrismLibrary/Prism) support so you can **Navigate**, create **Dialog Windows** and **Notifications**, provide **Dependency Injection** and internal **Messaging** easier than before! To help get started, check out the _[official Prism.Avalonia Templates](https://github.com/SuessLabs/Prism.Avalonia.Templates)_ for Visual Studio.

**For more samples outside of this repo, check out:**

* [Avalonia Outlookish](https://github.com/DamianSuess/Learn.PrismAvaloniaOutlookish)
* [Learn PrismLibrary](https://github.com/DamianSuess/Learn.PrismLibrary)
* _If you have samples, let us know and we'll feature them!_

![Sample Outlookish](https://raw.githubusercontent.com/AvaloniaCommunity/Prism.Avalonia/master/images/Sample-Outlookish.png)

Prism.Avalonia's logic and development approach is **similar** to that of [Prism for WPF](https://github.com/PrismLibrary/Prism/) so 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 and help us improve. 😃

## Package Releases

Just like _Prism.WPF or Prism.Maui_, your project must reference both the **Prism.Avalonia** (_Core_) and **Prism.DryIoc.Avalonia** (_IoC container_) packages to work.

| Package | Stable | Preview
|-|-|-|
| Prism.Avalonia | [![Prism.Avalonia NuGet Badge](https://img.shields.io/nuget/v/Prism.Avalonia)](https://www.nuget.org/packages/Prism.Avalonia/) | [![Prism.Avalonia NuGet Badge](https://img.shields.io/nuget/vpre/Prism.Avalonia)](https://www.nuget.org/packages/Prism.Avalonia/)
| Prism.DryIoc.Avalonia | [![Prism.DryIoc.Avalonia NuGet Badge](https://img.shields.io/nuget/v/Prism.DryIoc.Avalonia)](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/) | [![Prism.DryIoc.Avalonia NuGet Badge](https://img.shields.io/nuget/vpre/Prism.DryIoc.Avalonia)](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/)

### Version Notice

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 `v9.0.537.11234` equates to, Prism `v9.0.537`, Avalonia `v11.2.3`, _revision_ `4`.

| Prism | Avalonia | Prism.Avalonia NuGet Package
|-|-|-
| v8.1.97 | **11.0.7** | v8.1.97.11073 ([Core](https://www.nuget.org/packages/Prism.Avalonia/8.1.97.11073)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/8.1.97.11073))
| v8.1.97 | **0.10.21** | v8.1.97.1021 ([Core](https://www.nuget.org/packages/Prism.Avalonia/8.1.97.1021)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/8.1.97.1021))

Be sure to check out the [ChangeLog.md](ChangeLog.md) and guides when upgrading your NuGet packages:

* [Upgrading to Prism v9.0.x-pre](https://github.com/AvaloniaCommunity/Prism.Avalonia/wiki/Upgrading-to-Prism-v9.0)
* [Upgrading to Avalonia-11](Upgrading-to-Avalonia-11.md)
* Also, the official [Avalonia Upgrading from v0.10](https://docs.avaloniaui.net/docs/next/stay-up-to-date/upgrade-from-0.10).

## Contributing

See also, [Contributing.md](.github/Contributing.md)

Prism.Avalonia is an open-source project under the MIT license. We encourage community members like yourself to contribute.

You can contribute today by creating a **feature request**, **issue**, or **discussion** on the forum. From there we can have a brief discussion as to where this fits into the backlog priority. If this is something that fits within the Prism architecture, we'll kindly ask you to create a **Pull Request**. Any PR made without first having an issue/discussion may be closed.

Issues posted without a description may be closed immediately. Use the discussion boards if you have a question, not Issues.

## Install

Add the Prism.Avalonia and its DryIoc packages to your project:

```powershell
# Legacy: Avalonia v11.0
Install-Package Prism.Avalonia -Version 8.1.97.11073
Install-Package Prism.DryIoc.Avalonia -Version 8.1.97.11073

# 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

### Program.cs

The default Avalonia entrypoint `Program.cs` does not need to be modified. Below is provided as a sample.

```csharp
using System;
using Avalonia;

namespace SampleBaseApp;

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()
.UsePlatformDetect()
.WithInterFont()
.LogToTrace();
}

```

### App.axaml

```xml



```

### App.axaml.cs

> **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 ``. Prism takes care of this for you! (:

```csharp
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 override void Initialize()
{
AvaloniaXamlLoader.Load(this);
base.Initialize(); // Required to initialize Prism.Avalonia - DO NOT REMOVE
}

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

return Container.Resolve();
}

protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// Add Services and ViewModel registrations here

Console.WriteLine("RegisterTypes()");

// Services
//// containerRegistry.RegisterSingleton();

// Views - Region Navigation
//// containerRegistry.RegisterForNavigation();

// Dialogs
//// containerRegistry.RegisterDialog();
//// containerRegistry.RegisterDialogWindow(nameof(CustomDialogWindow));
}

protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
// Register modules
//// moduleCatalog.AddModule();
}
```

## House Keeping

### Branching Strategy

Below is a basic branching hierarchy and strategy.

| Branch | Purpose
|-|-|
| `master` | All releases are tagged published using the `master` branch
| `develop` | The **default** & active development branch. When a feature set is completed and ready for public release, the `develop` branch will be merged into `master` and a new NuGet package will be published.
| `feature/*` | New feature branch. Once completed, it is merged into `develop` and the branch must be deleted.
| `stable/*` | Stable release base build which shares cherry-picked merges from `develop`. This branch **must not** be deleted.

### Code of Conduct

See, [Code of Conduct](.github/Code-of-Conduct.md)

### Security

See, [Security](.github/Security.md)

**Sponsored by:** [Suess Labs](https://suesslabs.com) a subsidary of Xeno Innovations, Inc.