Xamarin Forms: Shared Images

I've recently undertaken a small side project that I've decided I'm going to use Xamarin Forms and for the fun/learning, I've picked F# as my language of choice. I'll note that if the app requires a backend I'm going to be using Elixir&Phoenix, but that's for another time. This might be a bit of a mini series explaining my experiences with this setup.

First off, let me make a quick, clear post on how you can use images across your .Droid & .iOS applications, for this I'm using a file called settings.png, which is a settings cog, because all good apps need some settings.

Firstly (see image below), with a relatively blank Xamarin Project built in (this case) VS for Mac (boo me all you want), create a folder called Resources, then put your image in there. Right click on said image -> Build Actions -> EmbeddedResource.

It's pretty simple really.

Then since I'm dabbling with F#, I use the following code to assign the image to the image in my xaml.

I mean come on, and I couldn't find a good resource for this!?

I imagine you could probably set it directly in your xaml if you wanted. But after an hour of build errors because VS for Mac is nice and user friendly I finally got this working. I hope this might help someone, someday.

Be Excellent.

R

Show Comments