Projektanker.Icons.Avalonia.MaterialDesign 3.7.0

Install-Package Projektanker.Icons.Avalonia.MaterialDesign -Version 3.7.0
dotnet add package Projektanker.Icons.Avalonia.MaterialDesign --version 3.7.0
<PackageReference Include="Projektanker.Icons.Avalonia.MaterialDesign" Version="3.7.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Projektanker.Icons.Avalonia.MaterialDesign --version 3.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Projektanker.Icons.Avalonia.MaterialDesign, 3.7.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Projektanker.Icons.Avalonia.MaterialDesign as a Cake Addin
#addin nuget:?package=Projektanker.Icons.Avalonia.MaterialDesign&version=3.7.0

// Install Projektanker.Icons.Avalonia.MaterialDesign as a Cake Tool
#tool nuget:?package=Projektanker.Icons.Avalonia.MaterialDesign&version=3.7.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Icons.Avalonia

A library to easily display icons in an Avalonia App.

CI-CD

NuGet

Name Description Version
Projektanker.Icons.Avalonia Core library Nuget
Projektanker.Icons.Avalonia.FontAwesome Font Awesome Free Nuget
Projektanker.Icons.Avalonia.MaterialDesign Material Design Icons Nuget

Icon providers

Name Prefix Example
FontAwesome fa fa-github
MaterialDesign mdi mdi-github

Usage

A full example is available in the demo directory.

1. Register icon providers on app start up

Register the icon provider(s) within the Main method before building the Avalonia app. Otherwise the visual designer won't be able to use the registered icon provider(s).

class Program
{
    // Initialization code. Don't use any Avalonia, third-party APIs or any
    // SynchronizationContext-reliant code before AppMain is called: things aren't initialized
    // yet and stuff might break.
    public static void Main(string[] args)
    {
        // Register icon provider(s)
        IconProvider.Register<FontAwesomeIconProvider>();
        IconProvider.Register<MaterialDesignIconProvider>();

        BuildAvaloniaApp()
            .StartWithClassicDesktopLifetime(args);
    }

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

2. Add xml namespace

Add xmlns:i="clr-namespace:Projektanker.Icons.Avalonia;assembly=Projektanker.Icons.Avalonia" to your view.

3. Use the icon

Example: The GitHub icon.
FontAwesome

<i class="fab fa-github"></i>

Standalone

<i:Icon Value="fab fa-github" />

Attached

<Button i:Attached.Icon="fab fa-github" />

Done

Screenshot

Implement your own Icon Provider

Just implement the IIconProvider interface:

namespace Projektanker.Icons.Avalonia
{
    /// <summary>
    /// Represents an icon provider.
    /// </summary>
    public interface IIconProvider
    {
        /// <summary>
        /// Gets the prefix of the <see cref="IIconProvider"/>.
        /// </summary>
        string Prefix { get; }

        /// <summary>
        /// Gets the SVG path of the requested icon using the registered icon providers.
        /// </summary>
        /// <param name="value">The value specifying the icon to return it's path from.</param>
        /// <returns>The path of the icon.</returns>
        /// <exception cref="System.Collections.Generic.KeyNotFoundException">The icon associated
        /// with the specified <paramref name="value"/> does not exists.</exception>
        string GetIconPath(string value);
    }
}

and register it with the IconProvider:

IconProvider.Register<MyCustomIconProvider>()

or

IIconProvider provider = new MyCustomIconProvider(/* custom ctor arguments */);
IconProvider.Register(provider);

The IIconProvider.Prefix property has to be unique within all registered providers. It is used to select the right provider. E.g. FontAwesomeIconProvider's prefix is fa.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
3.7.0 888 11/20/2021
3.6.0 144 11/14/2021
3.5.0 80 11/12/2021
3.4.1 78 11/8/2021
3.4.0 96 11/8/2021
3.3.0 184 10/25/2021
3.2.0 149 10/17/2021