Xamarin Forms everywhere

Xamarin Forms everywhere

2021, Jan 22    

Xamarin Forms is multiplatform with as much code-reuse as possible. I worked quite some time with iOS and android, but never had set foot to other platforms, so I wanted to see how well Xamarin Forms works out of the box on other platforms with the focus on desktop.

I wanted to cover

  • iOS
  • Android
  • Windows (UWP/WPF)
  • Linux (GTK)
  • macOS (“standard” and Frank Kruger’s Catalyst version)

I used the Vs4mac Template for multiplatform app with flyout, non-shell. I updated everything to the latest Xamarin Forms and Essentials.

I documented my efforts in a github repo: https://github.com/hot33331/XamarinFormsEverywhere

UPDATE: As James Montemagno pointed out on twitter I forgot to mention that only UWP is supported by Microsoft as a Desktop environment for Xamarin Forms all the other projects are a community effort and / or only in preview.

iOS

As expected iOS works great, no hiccups, everything is fine.

iOS screenshot

android

See iOS.

iOS screenshot

Windows

UWP

Here’s how to add a UWP project to your forms project (link to the docs).

Now this is where things get interesting. UWP runs okay if you know that you have to click on the dots in the upper right to get the menu for adding things.

uwp1 screenshot

uwp2 screenshot

uwp3 screenshot

WPF (preview)

Here’s how to add a WPF project to your forms project (link to the docs).

WPF does not show any items or the flyout. However if you click around in the white space you might manage to popuot that flyout (see second screenshot).

wpf1 screenshot

wpf2 screenshot

Linux (GTK 2 - preview)

Here’s how to add a GTK project to your forms project (link to the docs).

You can develop easily from your mac for GTK (gets installed with Visual Studio) and run that same code on Linux (I testet on Ubuntu with Mono Develop IDE - you could also use jetbrains Rider on Linux). Unfortunately it also does not seem to be very mature, yet and does not show any items.

gtk1 screenshot

Clicking around in the white space also reveals the flyout as in WPF.

gtk2 screenshot

macOS

Here’s how to add a macOS project to your forms project (link to the docs).

While the “out-of-the-box” project does have some hiccups: not showing items and action button.

macOS screenshot

The catalyst version (using Frank Krugers nuget) works flawless and snappy:

macCatalyst screenshot

but it is still in alpha state and if I remember correctly apps cannot be signed for the app store, just yet.

Conclusion

I was pretty disappointed by the desktop implementations. I had the expectation that the basic file - new - template would work at least. Unfortunately only UWP worked with one minor complaint. I have high hopes that the support for desktop will get better with .net 6 and MAUI since I think I remember from some of David Ortinau’s slides that Windows (WinUI3 in the future) and macOs (hopefully Frank’s catalyst version) will be supported by Microsoft. From my point of view the current state of Desktop (maybe with exception of UWP) in Xamarin Forms 5 is not ready for production use, yet.

This however shall not diminish the great efforts of the community, trying to get Xamarin Forms to the desktop.

Thanks to Gerald Versluis for all the handy videos that helped me a great deal! Watch his videos here: Gerald.Codes(Xamarin.Forms);

P.S. I found some proof for my earlier claims in one of the videos from .net Frontend Day.

mssupport screenshot

winui3_catalyst screenshot