How to WIN with Xamarin.Forms

‘Xamarin is not ready’ a statement I heard recently. What do you think?

Anyone that’s experienced in Xamarin knows this is an inaccurate statement, there’s been a huge amount of successful Native applications built with Xamarin including apps like RDIO, Storyo and iCircuit and apps from large corporations like Banks, Tesco and Microsoft. You probably already know I’m a Xamarin lover, but in this blog I’m going to give you a real honest view.

While the statement is inaccurate I can also understand how someone could come to this conclusion, especially if their first experience is with Forms and even more so if they’ve had Native app development experience before. The reason for this is that 1) Xamarin.Forms is still only months old (some argue it’s still beta quality), to be perfectly honest when Xamarin.Forms was released it did kind of match the promises but it was buggy and lacking features so it was basically a beta release (when compared with Microsoft products). 2) When you come from a experienced App development background there’s certain ways you want an app to work and with Forms it can be difficult to break out of the standard API and do you own thing. Initially I struggled with this and was a little frustrated. I eventually learnt to ‘not to fight the framework’ As Xamarin.Forms is a abstract API which means certain there’s ways it works and strengths/weaknesses, it’s a trade off.

The first thing you need to understand is that Xamarin is not Xamarin.Forms, the core of what made Xamarin famous is ‘Xamarin  Traditional’ eg Xamarin.iOS and Xamarin.Android. ‘Xamarin Traditional’ is absolutely rock solid, when you develop an app in ‘Xamarin Traditional’ it can be as fast, stable and functional as any Native app.

While there’s issues with Forms, I’ve adopted it in the majority of apps. Why? Because even though it kinda sucks, it sucks less than all the other options like 1) building/coding it on all platforms 2) a clunky PhoneGap app. If you know how to harness it’s goods part and avoid the bad parts then it’s actually very powerful, especially how you can jump in/out of Native Code/Bind Native libraries and even use HybridWebViews. Over the past 6 months I’ve delivered many Forms apps for clients so below I’m going to give some tips on how you can WIN with Xamarin.Forms.

Understand what the Framework can and can’t do

Xamarin.Forms is an abstraction on the top of Xamarin.iOS and Xamarin.Android it’s major advantage is that you can program to a single api(with Databinding) and have it render natively, but there’s a bunch of caveats for example 1) ListView performance isn’t great, so it’s not recommended for super large lists of data 2) Sometimes renderering of pages with many controls is slow. Now both these issues can be worked around, in both these cases you can use a custom renderer.

Don’t fight the Framework

This is a big one others have also commented on this. This one become especially challenging for people experienced in native apps/xamarin traditional as normally they(like me) bring in certain expectations and ways they want things to work. In Xamarin.Forms you need to let go any preconceptions of how you want something to work, you need to learn the Xamarin.Forms way to do it. If you try to treat Xamarin.Forms like a iOS API then it’s going to be painful.

Use the Forums

One of the great places to keep updated and have questions answered is the Xamarin forums, it’s the most active place for Xamarin.Forms even more active than StackOverflow. I definitely recommend spending some time in the forums, new releases and updates are notified on these forums. The address is forums.xamarin.com.

Learn from github

As most developers know the best way to learn code is to read and write code. When learning Xamarin.Forms I found the github the most useful resource, James and Craig from Xamarin have some great github repos and there’s also the official one from Xamarin.

Xamarin.Forms Xaml is not WPF

WPF is Xaml and so it Xamarin.Forms so it makes logical sense that if your good at WPF you’ll be good at Forms, but this far from the truth now and probably into the future. WPF was built for a single platform and built by the creators of that platform(Microsoft) with a huge amount of resources, so even on v1 it was very functional and stable. Xamarin.Forms is very different for a few reasons 1) it was built for multiple platforms 2) it was built by a small team and released very early 2)  it still suffers low-common dominator issues. As it stands if you’re building a serious app with Xamarin.Forms it’s likely you’ll hit the limits of Forms in the first few days and you’ll end up spending a lot of time in custom renders programming the Native API. Which isn’t a problem really, as the native API’s are great, it’s only a problem if you think you whole app is going to be Xaml and a WPF developer is going to rock at it.

Use it on the correct app

Using Xamarin.Forms is a trade off, the advantage of Forms is that you’ve got a single API which maps to native controls but the disadvantage is that it’s a abstract API and your bound to the API unless you want to do custom renderers. Taking the RunKeeper app for an example, as it stands in Jan 2015 in Xamarin.Forms you definitely wouldn’t be able to pull off the RunKeeper app and the best option is to use Xamarin.Traditional.

Dig into the source

In Xamarin Studio your able to look at the source for Xamarin.Forms using the built in Assembly viewer and there’s also products that allow you to decompile source such as reflector or ILSpy.

In a normal work day on Xamarin.Forms I’ll dig into a custom renderers code at least once. I found this insanely useful as it allows me to understand what’s going on underneath the surface in Xamarin.Forms and work around issues or come up with creative solutions to issues.

Some bonus places to keep upto date with Xamarin.Forms

Xamarin Weekly Newsletter – always manages to find some blogs that I’ve missed.

Xamarin Documentation – it’s a bit behind the githubs/forums but it’s still good

Planet Xamarin – this is the compiled blogs of many Xamarin Guru’s

Sydney Xamarin Guy – can’t forget my blog of course

Hopefully this blog post has giving you some insights into Xamarin.Forms and how to be productive with Xamarin.Forms.

Thanks

Michael

 

 

 

 

3 Responses

  1. Very nice article.
    I wish you could gave more caveats, it’s the most interesting thing to read from other’s experience.
    Maybe a separate post talking more on the pitfalls…

  2. Thanks for your nice post! I am also convinced that there is good things with Xamarin.Forms.

    In you posts, you say “In Xamarin Studio your able to look at the source for Xamarin.Forms using the built in Assembly viewer and there’s also products that allow you to decompile source such as reflector or ILSpy.”

    But in the Assembly viewer, it is only possible to see the class definitions and properties, no the implementation?

  3. Really great post,

    I’m getting into xamarin.forms at the moment and what you’ve written definitely echoes my current thinking, although I’m clearly some way behind you!

    I definitely need to look at custom renderers more and be more open to using them. They seem pretty intimidating and if I’m honest the documentation around them isn’t the best.

    One other issue that I’ve found is that I’ve hit straight into xamarin with xamarin.forms, without any real grounding in xamarin.ios or xamarin.android (I have done some android native work). I think you really need to have a solid understanding of xamarinf.ios/android to get the most from forms – you cant just learn xamarin forms!

Leave a Reply to Mike Cancel reply