Replace difficult Fontawesome codes with an easy property

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="&#xf17b;" 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:

fontawesomeicons

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!