Xamarin.Forms coding technique

Image source – Pixabay

Xamarin.Forms is an open-source, cross-platform framework. It was developed by Microsoft for building mobile apps. These apps can run on iOS, Android, and Windows operating systems. Note that Xamarin is the parent framework of Xamarin.Forms. It is a mobile development framework that makes use of the .NET developer platform for building mobile apps. Xamarin.Forms comes with built-in controls, layouts, and pages. These features make building and developing mobile apps from a single, highly extensible API possible. Xamarin.forms enables developers to build mobile apps for Windows, iOS, and Android from the same shared codebase. Hence, for better productivity with Xamarin.Forms, we have compiled some of the best techniques, tips, and tricks.

Page navigation in Xamarin.Forms

Mobile apps are mostly a collection of pages. Consequently, the ability to intuitively navigate through these pages decides the user-friendliness of the app. Above all, an intuitive interface makes navigating through the app pages smooth. Xamarin.Forms come with a built-in navigation model. Movement of pages in Xamarin.Forms follow the Last-in-First-out (LIFO) pattern. To clarify, a page is stacked on top when it is selected. Returning to the previous page moves it out of the stack. The NavigationPage class can be used to get a grip of the built-in navigation model of Xamarin.Forms. The NavigationPage class adds a navigation bar to the top of the app page. Moreover, you have the option of adding icons and titles. A back navigation button is also present, depending on the mobile platform.

Nested Stack Layout

Using nested StackLayout makes an app very difficult to understand or read. Subsequently, nested StackLayout negatively impacts the app’s performance. If using nested StackLayout is a necessity, a good option is using multiple children with a single parent StackLayout. If using StackLayout is not a compulsion, a grid is a more efficient choice. Basically, a grid lets developers read the code and improve the app’s performance easily.

Data Persistence Strategy

A consistent data persistence strategy is crucial for your Xamarin.Forms app. As a result of dependence on the cloud, your app will stop working without internet connectivity. If your app can cache data once it is downloaded, your app will keep functioning seamlessly without connectivity. Your apps need to have some user and app-specific data to be stored as a cache between two or more uses of the app. For your data persistence strategy, you would preferably want a cross-platform model that functions in all environments. An easy option to achieve this is to use one of Xamarin.Forms’ built-in dictionaries.

MVVM Framework

The standard rule to choose between Model-View-ViewModel (MVVM) frameworks is to pick the simplest one. MVVM pattern segregates domain logic and presentation layer. That is to say, if you ignore the MVVM pattern, you cannot use the code again. MVVM patterns are useful because they make the code easy to use multiple times. It is also easier to work out problems, maintain and test. Xamarin supports the MVVM pattern, including data binding. This leads to a more robustly tested application code. As a result, it is also easier to extend these codes without any major changes.


  1. 5 Helpful Xamarin Developer Tips – Telerik Blogs
  2. 10 Tips to Avoid Common Mistakes in Xamarin.Forms App Development | Syncfusion Blogs
  3. Xamarin.Forms: Tips for Beating the Learning Curve | Xamarin Blog (microsoft.com)
  4. Tips and Tricks about Xamarin.Forms – Altkom Software & Consulting
  5. Xamarin.Forms | .NET (microsoft.com)