Some extensions to quickly build Avalonia UI desktop applications without needing XAML. Built on top of Avalonia.Markup.Declarative.
Note that while using these extensions allow you to very quickly setup an application, they do somewhat push you into using Avalonia UI my way, rather than extending Avalonia UI generically.
You can install the avalonia extensions via the NuGet package Mattias1.AvaloniaExtensions.
This is a simple example application:
using AvaloniaExtensions;
AvaloniaExtensionsApp.Init().StartDesktopApp("Example app", () => new ReadmeComponent());
public class ReadmeComponent : CanvasComponentBase {
protected override void InitializeControls() {
AddTextBlock("A simple example application").TopLeftInPanel();
AddButton("Cancel").BottomRightInPanel();
AddButton("Ok").LeftOf();
}
}
For a more elaborate example, you can take a look at the Example App source.
- Clone the Avalonia.Markup.Declarative repo in the 'lib' folder
- Copy the needed files to the 'AvaloniaExtensions/lib/Avalonia.Markup.Declarative' folder with
mkdir -p AvaloniaExtensions/lib/Avalonia.Markup.Declarative/ cd lib/Avalonia.Markup.Declarative/src/Avalonia.Markup.Declarative/ cp -r --parents *.cs ../../../../AvaloniaExtensions/lib/Avalonia.Markup.Declarative/ cp -r --parents **/*.cs ../../../../AvaloniaExtensions/lib/Avalonia.Markup.Declarative/ cd ../../../../
- Start the example app with
cd ExampleApp/ && dotnet run
Create a github release with a tag named 'vx.y.z'.