AvaloniaMenuFactory 0.1.1

Suggested Alternatives

MenuFactory

There is a newer version of this package available.
See the version list below for details.
dotnet add package AvaloniaMenuFactory --version 0.1.1                
NuGet\Install-Package AvaloniaMenuFactory -Version 0.1.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AvaloniaMenuFactory" Version="0.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add AvaloniaMenuFactory --version 0.1.1                
#r "nuget: AvaloniaMenuFactory, 0.1.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install AvaloniaMenuFactory as a Cake Addin
#addin nuget:?package=AvaloniaMenuFactory&version=0.1.1

// Install AvaloniaMenuFactory as a Cake Tool
#tool nuget:?package=AvaloniaMenuFactory&version=0.1.1                

Avalonia.MenuFactory

NuGet NuGet

Avalonia Menu Factory is a dynamic UI library that lets you seamlessly implement and manage a menu bar in your Avalonia application from only a class, where each function is a menu item.

Usage

Avalonia Menu Factory works by reading a decorated class of methods and sending the results into an Menu control.

Use the static MenuFactory.Generate() method, passing in an instance of your menu class to create the menu items. These items can then be assigned to the Menu.Items property.

MenuRoot = this.FindControl<Menu>("MenuRoot")!;

MenuModel menuModel = new();
MenuRoot.Items = MenuFactory.Generate(menuModel);

<br>

To build your menu class, decorate each method with the Avalonia.MenuFactory.MenuAttribute attribute where you can specify the MenuItem name, navigation path (e.g. About/Help for About > Help > {method}), icon, and hotkey.

[Menu("Exit", "_File", Icon = MaterialIconKind.ExitToApp, HotKey = "Alt + F4")]
public static void Exit()
{
    Environment.Exit(0);
}

[Menu("Readme", "_About/Help", Icon = MaterialIconKind.HelpOutline)]
public static void Readme()
{
    Debug.WriteLine(File.ReadAllText("../ReadMe.md"));
    // ...
}

[Menu("Credits", "_About", Icon = MaterialIconKind.PersonCheck)]
public static async void Credits()
{
    Debug.WriteLine(File.ReadAllText("../Credits.md"));
    // ...
}

The previous two examples will build the following menu:

<img height="195" src="https://user-images.githubusercontent.com/80713508/198862474-55c4f195-a48b-4cdd-8c2f-61739948e576.png"> <img style="border-radius: 3px;" height="195" src="https://user-images.githubusercontent.com/80713508/198863017-48240fbb-f8ee-42e8-aea5-f66d366ea428.png">

Install

Install with NuGet or build from source.

NuGet
Install-Package AvaloniaMenuFactory
Build from Source
git clone https://github.com/ArchLeaders/Avalonia.MenuFactory.git
dotnet build Avalonia.MenuFactory

© 2022 Arch Leaders

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on AvaloniaMenuFactory:

Package Downloads
AvaloniaGenerics

Generic UI wrappers and helpers for AvaloniaUI

GitHub repositories (1)

Showing the top 1 popular GitHub repositories that depend on AvaloniaMenuFactory:

Repository Stars
DeltaJordan/BotW-Save-Manager
BOTW Save Manager for Switch and Wii U