Replace difficult Fontawesome codes with an easy property

By Marco Troncone · · 1 min read
First published on xamarinexpert.it in 2020. It was written for Xamarin, which reached end of support in May 2024: the ideas still apply to .NET MAUI, but some APIs and tools have changed.

As you definitely know, you can use the amazing FontAwesome icons in your Xamarin projects on Android, iOS and Windows. (if you don't know how, follow this easy guide here).

The only difficult thing you have to do to add an icon in your app is to find and then write it's code correctly.

For example the code the Android icon is: f17b so in your XAML you should have something like this:

<Label FontFamily="FAB" Text="" TextColor="Green" />

Not very difficult but definitely not very clear.

Now thanks to Matthew Robbins you can replace that code with something like:

<Label FontFamily="FAB" Text="{x:Static fontawesome:FontAwesomeIcons.Android}" TextColor="Green" />

There are two main reasons to do it, the first one is that with the new syntax, even after months you know what icon you are using and the second is that this works with Intellisense so it will be incredibly easy to add you icons.

To use this new syntax you need to download this file

FontAwesomeIcons.cs

and copy it in your project, like this:

That's it. Now you are ready to use the new syntax!

If you have any questions or issues, leave me a comment down here!

Need help with your app?

I build and rescue .NET MAUI, Xamarin, Android and iOS apps, and I'm available for contract and consulting work.

Hire me

← All articles