Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/AvaloniaCommunity/Prism.Avalonia
Prism framework support for Avalonia UI
https://github.com/AvaloniaCommunity/Prism.Avalonia
avalonia csharp dependency-injection dotnet dotnetcore mvvm net6 net7 prism prismavalonia
Last synced: about 2 months ago
JSON representation
Prism framework support for Avalonia UI
- Host: GitHub
- URL: https://github.com/AvaloniaCommunity/Prism.Avalonia
- Owner: AvaloniaCommunity
- License: mit
- Created: 2019-12-31T17:22:40.000Z (over 4 years ago)
- Default Branch: develop
- Last Pushed: 2024-04-13T14:16:49.000Z (5 months ago)
- Last Synced: 2024-04-13T18:52:18.487Z (5 months ago)
- Topics: avalonia, csharp, dependency-injection, dotnet, dotnetcore, mvvm, net6, net7, prism, prismavalonia
- Language: C#
- Homepage: https://www.nuget.org/packages/Prism.Avalonia/
- Size: 1.02 MB
- Stars: 256
- Watchers: 14
- Forks: 35
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
- awesome-avalonia - Prism - Prism framework support for Avalonia UI. (Libraries & Extensions / MVVM & MVP & MVU)
README
# Prism.Avalonia
[Prism.Avalonia](https://github.com/AvaloniaCommunity/Prism.Avalonia) provides your [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!**
>
> * _Prism.Avalonia v9.0.401-pre just arrived!_
> * _Prism.Avalonia v9.0.271-pre just 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**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/stable/v8.1.97.11xx/logo/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.
## 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://buildstats.info/nuget/Prism.Avalonia?dWidth=70&includePreReleases=false)](https://www.nuget.org/packages/Prism.Avalonia/) | [![Prism.Avalonia NuGet Badge](https://buildstats.info/nuget/Prism.Avalonia?dWidth=70&includePreReleases=true)](https://www.nuget.org/packages/Prism.Avalonia/)
| Prism.DryIoc.Avalonia | [![Prism.DryIoc.Avalonia NuGet Badge](https://buildstats.info/nuget/Prism.DryIoc.Avalonia?dWidth=70&includePreReleases=false)](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/) | [![Prism.DryIoc.Avalonia NuGet Badge](https://buildstats.info/nuget/Prism.DryIoc.Avalonia?dWidth=70&includePreReleases=true)](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 `v8.1.97.11073` equates to, Prism `v8.1.97`, Avalonia `v11.0.7`, _revision_ `3`.
| Prism Version | Avalonia Version | NuGet Package
|-|-|-
| v9.0.401-pre | **11.0.7** | v9.0.401.11000-pre ([Core](https://www.nuget.org/packages/Prism.Avalonia/9.0.401.11000-pre)) ([DryIoc](https://www.nuget.org/packages/Prism.DryIoc.Avalonia/9.0.401.11000-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))
| 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
# Avalonia v11
Install-Package Prism.Avalonia -Version 8.1.97.11073
Install-Package Prism.DryIoc.Avalonia -Version 8.1.97.11073# 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");public static AppBuilder BuildAvaloniaApp() =>
AppBuilder
.Configure()
.UsePlatformDetect();public override void Initialize()
{
AvaloniaXamlLoader.Load(this);
base.Initialize(); // <-- Required
}protected override void RegisterTypes(IContainerRegistry containerRegistry)
{
// Register Services
containerRegistry.Register();// Views - Generic
containerRegistry.Register();// Views - Region Navigation
containerRegistry.RegisterForNavigation();
containerRegistry.RegisterForNavigation();
containerRegistry.RegisterForNavigation();
}protected override AvaloniaObject CreateShell()
{
if (IsSingleViewLifetime)
return Container.Resolve(); // For Linux Framebuffer or DRM
else
return Container.Resolve();
}protected override void ConfigureModuleCatalog(IModuleCatalog moduleCatalog)
{
// Register modules
moduleCatalog.AddModule();
moduleCatalog.AddModule();
moduleCatalog.AddModule();
}/// Called after .
protected override void OnInitialized()
{
// Register initial Views to Region.
var regionManager = Container.Resolve();
regionManager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(DashboardView));
regionManager.RegisterViewWithRegion(RegionNames.SidebarRegion, typeof(SidebarView));
}
}
```### Program.cs
Your default Avalonia `Program.cs` file does not need to be modified. Below is provided as a sample.
```csharp
public static class Program
{
public static AppBuilder BuildAvaloniaApp() =>
AppBuilder.Configure()
.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);
}static void SilenceConsole()
{
new Thread(() =>
{
Console.CursorVisible = false;
while (true)
Console.ReadKey(true);
})
{ IsBackground = true }.Start();
}
}
```## 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.