Talently
Talently
Xamarin Forms

Xamarin Forms

The .NET framework for cross-platform mobile applications

Xamarin Forms is a Microsoft framework for building cross-platform mobile applications for iOS and Android using C# and .NET with a shared user interface. It allows .NET developers to build native applications with a single codebase in C#, accessing device APIs and compiling to native code for each platform. It is currently being replaced by .NET MAUI as its official successor.

C#.NETXAMLMobile

Market demand

Xamarin Forms has stable demand especially in companies with .NET teams that need mobile presence without adopting new technologies. With the transition toward .NET MAUI, new projects tend to use MAUI, but maintaining existing Xamarin projects continues to generate market demand.

Demand in maintenance of existing projectsHigh adoption in .NET ecosystemActive transition toward .NET MAUI

Technical requirements

Intermediate

Requires mastery of C#, object-oriented programming, and familiarity with the .NET ecosystem. Knowledge of XAML for defining user interfaces and understanding of the MVVM pattern is essential for well-structured Xamarin Forms projects.

Use cases

Real Projects

Xamarin Forms is used to develop:

  • Enterprise mobile applications in .NET ecosystems
  • Internal productivity apps for employees
  • Field applications with device API access
  • Mobile systems integrated with .NET backends or Azure

Types of Company

Xamarin Forms is adopted by:

  • Companies with .NET teams that need mobile applications
  • Organizations in the Microsoft ecosystem with Azure stack
  • Companies migrating WPF or WinForms applications to mobile
  • Companies with ERP or CRM systems that need a mobile client

Production Scenarios

Xamarin Forms is widely used in production environments such as:

  • Applications with Azure AD authentication and MSAL
  • Apps with camera, GPS, and device sensor access
  • Applications with offline mode and synchronization with .NET backend
  • Systems with deep integration with Microsoft services like Office 365

Scalability

Xamarin Forms offers multiple mechanisms to scale applications:

  • Shell for structured navigation in complex applications
  • DependencyService for platform-specific native functionality access
  • MessagingCenter for decoupled communication between components
  • Lazy loading of pages to optimize startup time

Advantages and Disadvantages

Advantages

Reuse of C# and .NET knowledge for mobile development without new languages.

Natural integration with the Microsoft ecosystem including Azure and Active Directory.

Compilation to native code that offers better performance than WebView solutions.

Disadvantages

In the process of deprecation with .NET MAUI as the recommended successor for new projects.

Learning curve in XAML and in behavior differences between platforms.

Smaller community than React Native or Flutter with fewer available resources.

Comparison

Advantages of .NET MAUI

  • Official successor with long-term Microsoft support
  • Additional support for Windows and macOS beyond mobile
  • Improved architecture with better performance and tooling

Considerations

MAUI is the direct successor to Xamarin Forms with the same philosophy but modernized architecture. For new projects, MAUI is the recommended option. Xamarin Forms remains relevant for maintaining existing projects.

Basic questions

Xamarin Forms allows reusing the existing team's C# and .NET knowledge without adopting JavaScript or the npm ecosystem. Integration with Azure, Azure Active Directory, and other Microsoft services is more natural and compilation to native code offers better performance than WebView solutions.
Xamarin Forms shares the user interface between platforms through abstract controls that render as native components on each platform. Xamarin native shares business logic in C# but defines the UI specifically for each platform with native iOS and Android components, offering greater control but less reuse.
MVVM separates the View in XAML from the ViewModel with presentation logic and the Model with data. Xamarin's data binding connects the View with the ViewModel without code-behind code, making the code more testable, maintainable, and reusable. It is the recommended pattern because it facilitates unit testing of the ViewModel without depending on the UI.
XAML is more readable for defining UI hierarchies, allows separating visual structure from logic in code-behind, and is compatible with visual designers. Data binding is expressed more clearly in XAML and non-technical designers can understand and modify the structure without knowing C#.
Through DependencyService which allows defining an interface in shared code and implementing it in each platform project with the Dependency attribute. The shared code calls the interface and Xamarin resolves the correct implementation for iOS or Android at runtime.
Xamarin Forms is in maintenance mode with .NET MAUI as its official successor. Microsoft recommends MAUI for new projects. For organizations with existing Xamarin Forms projects, migration to MAUI is the recommended path, although Xamarin Forms support continues until May 2024.
Shell provides a simplified navigation structure for applications with flyout menu, tabs, and page stack configured in a single XAML file. It simplifies the navigation architecture of complex applications without manually managing NavigationPage, TabbedPage, and FlyoutPage separately.
In companies with established .NET teams that need mobile applications integrated with Microsoft systems, in projects with security requirements that favor the Microsoft ecosystem, or in organizations where reusing C# knowledge and Azure Active Directory integration are determining factors.

Technical questions

By binding ViewModel properties with Mode=TwoWay in XAML and ensuring the ViewModel implements INotifyPropertyChanged notifying changes with OnPropertyChanged. The page's BindingContext is set to the ViewModel and the framework manages automatic synchronization between the UI and the ViewModel.
Commands implement ICommand and are bound to actions in XAML with Command binding, keeping logic in the ViewModel and facilitating unit testing. Event handlers in code-behind couple logic to the View and are harder to test. Commands are the recommended practice in MVVM.
Using a navigation service injected into ViewModels that abstracts Xamarin's NavigationPage, allowing navigation from the ViewModel without direct references to the View. Frameworks like Prism or MvvmCross provide these navigation services already implemented with support for parameter passing between pages.
By creating a class that inherits from the corresponding native renderer in each platform project and decorating it with ExportRenderer. This allows customizing the visual or behavioral behavior of a Xamarin control beyond what standard properties allow, directly accessing the underlying native control.
By overriding the OnStart, OnSleep, and OnResume methods in the App class to manage application state when starting, going to the background, and returning to the foreground. For individual page lifecycle, OnAppearing and OnDisappearing are used which execute when navigating to or away from the page.
Using the MSAL library for Xamarin that manages the OAuth2 flow with Azure AD. The MSAL client is configured with the ClientId and Tenant, AcquireTokenInteractive is called for initial authentication with the system UI, and AcquireTokenSilent for renewing tokens without user interaction, storing the token in the MSAL cache.
CollectionView is the modern implementation that replaces ListView with better performance, support for grid and horizontal layouts, multiple selection, and without mandatory separators. ListView has greater compatibility with older versions but CollectionView is the recommended option for new projects due to its greater flexibility and performance.
Using Xamarin Essentials Preferences for simple key-value data, SQLite with sqlite-net-pcl for structured data with queries, or Akavache for object caching with persistence. The choice depends on data complexity, search requirements, and whether synchronization with a backend is needed.

Advanced questions

Using Prism as the MVVM framework that provides dependency injection, ViewModel-based navigation, dynamically loadable modules, and decoupled event management. The application is divided into independent module projects that register in the Prism container, facilitating parallel development by different teams.
Using Microsoft's upgrade assistant that automates much of the changes in project files and namespace references, migrating from Renderers to Handlers which is MAUI's new model, updating NuGet dependencies to MAUI-compatible versions, and verifying behavior on each platform after migration.
Using CollectionView with RecycleElement strategy to reuse cells, implementing lazy image loading with FFImageLoading, reducing cell visual complexity by minimizing nested layouts, using BindableLayout only for small lists, and considering virtualization with DataVirtualization for very large datasets.
Using Appium with the Xamarin.UITest driver that allows interacting with native controls by AutomationId on iOS and Android. Tests are written in C# and run on real devices or emulators in services like App Center Test or BrowserStack, verifying critical user flows in an automated manner.
By implementing a repository layer that abstracts the data source, using SQLite as the local store, differential synchronization with the server when connectivity is available, sync conflict management with a last-write-wins or merge strategy depending on the domain, and Xamarin Essentials Connectivity API to detect network changes.
When the project is in maintenance phase with a low rate of changes and migration doesn't provide immediate business value, when there are critical dependencies on Xamarin plugins without a MAUI equivalent yet, or when the team is in the process of gradually adopting .NET MAUI starting with new projects.

Common interview mistakes

Not knowing that Xamarin Forms is in the process of deprecation and that MAUI is its official successor reflects a lack of ecosystem follow-up. In current interviews, knowledge of the framework's state and implications for new and existing projects is expected.
Putting business logic in the code-behind of XAML pages instead of the ViewModel reflects not understanding the MVVM pattern that is fundamental in Xamarin Forms. It is one of the most frequent and visible anti-patterns in code reviews.
Using event handlers in code-behind instead of Commands bound to the ViewModel couples logic to the View and makes testing difficult. In interviews, knowledge of ICommand and RelayCommand as part of the MVVM pattern in Xamarin Forms is expected.
Not knowing how to access platform-specific functionalities from shared code reflects limited experience developing Xamarin Forms applications with requirements beyond basic UI.
Proposing Xamarin Forms for a new project without evaluating .NET MAUI reflects being out of date. Knowledge that MAUI is the recommended option for new projects and being able to articulate when starting with Xamarin Forms still makes sense is expected.
Using ListView for new list implementations without knowing CollectionView reflects not following current Xamarin Forms recommendations. CollectionView is more efficient and flexible and is the recommended practice in current versions.