Projektanker.Icons.Avalonia.FontAwesome 3.7.0
Icons.Avalonia
A library to easily display icons in an Avalonia App.
NuGet
Name | Description | Version |
---|---|---|
Projektanker.Icons.Avalonia | Core library | |
Projektanker.Icons.Avalonia.FontAwesome | Font Awesome Free | |
Projektanker.Icons.Avalonia.MaterialDesign | Material Design Icons |
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
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
.
No packages depend on Projektanker.Icons.Avalonia.FontAwesome.
.NET Standard 2.0
- Projektanker.Icons.Avalonia (>= 3.7.0)
- Newtonsoft.Json (>= 12.0.3)
Version | Downloads | Last updated |
---|---|---|
9.4.1 | 1 | 11/15/2024 |
9.4.0 | 4 | 08/25/2024 |
9.3.0 | 8 | 07/11/2024 |
9.2.0 | 8 | 07/11/2024 |
9.1.2 | 5 | 07/11/2024 |
9.1.1 | 8 | 07/11/2024 |
9.0.1 | 9 | 07/11/2024 |
9.0.0 | 9 | 07/11/2024 |
8.4.0 | 11 | 07/11/2024 |
8.3.0 | 11 | 07/11/2024 |
8.2.0 | 5 | 07/11/2024 |
8.1.0 | 11 | 06/23/2024 |
8.0.0 | 9 | 07/11/2024 |
7.0.1 | 4 | 07/11/2024 |
7.0.0 | 8 | 07/11/2024 |
6.6.0 | 8 | 07/11/2024 |
6.6.0-rc1.1 | 4 | 08/26/2024 |
6.6.0-preview6 | 7 | 07/11/2024 |
6.5.0-preview6 | 5 | 07/11/2024 |
6.5.0-preview5 | 8 | 07/11/2024 |
6.4.0-preview5 | 9 | 07/11/2024 |
6.3.0-preview4 | 7 | 07/11/2024 |
6.2.0-preview1 | 8 | 07/11/2024 |
6.1.0-preview1 | 8 | 07/11/2024 |
6.0.0-preview1 | 8 | 07/11/2024 |
5.13.0 | 8 | 07/11/2024 |
5.12.0 | 8 | 07/11/2024 |
5.11.0 | 5 | 07/11/2024 |
5.10.0 | 8 | 07/11/2024 |
5.9.0 | 8 | 07/11/2024 |
5.8.0 | 8 | 07/11/2024 |
5.7.0 | 6 | 07/11/2024 |
5.6.0 | 8 | 07/11/2024 |
5.5.0 | 8 | 07/11/2024 |
5.4.0 | 8 | 07/11/2024 |
5.3.0 | 8 | 07/11/2024 |
5.2.0 | 8 | 07/11/2024 |
5.1.0 | 9 | 07/11/2024 |
5.0.2 | 9 | 07/11/2024 |
5.0.1 | 7 | 07/11/2024 |
5.0.0 | 8 | 07/11/2024 |
4.5.0 | 3 | 07/11/2024 |
4.4.0 | 8 | 07/11/2024 |
4.3.0 | 6 | 07/11/2024 |
4.2.1 | 6 | 07/11/2024 |
4.2.0 | 9 | 07/11/2024 |
4.1.0 | 5 | 07/11/2024 |
4.0.1 | 6 | 07/11/2024 |
4.0.0 | 8 | 07/11/2024 |
3.7.1 | 7 | 07/11/2024 |
3.7.0 | 6 | 07/11/2024 |
3.5.0 | 8 | 07/11/2024 |
3.4.1 | 8 | 07/11/2024 |
3.4.0 | 8 | 07/11/2024 |
3.2.0 | 5 | 07/11/2024 |
3.1.4 | 8 | 07/11/2024 |
3.1.2 | 7 | 07/11/2024 |
3.1.1 | 6 | 07/11/2024 |
3.1.0 | 3 | 07/11/2024 |
3.0.0-pre | 5 | 07/11/2024 |
2.0.2 | 5 | 07/11/2024 |
2.0.1 | 7 | 07/11/2024 |
2.0.0 | 4 | 07/11/2024 |
1.1.0 | 3 | 07/11/2024 |
1.0.0 | 2 | 07/11/2024 |