3 Big Things To Explore in the Xamarin.Forms 2.5.0 Pre-Release

David Ortinau


Over the past year we’ve been working on a couple of “big things” that enable you to create more performant applications on more platforms. With our latest stable release, version 2.4.0, we introduced performance optimized renderers on Android, nicknamed Fast Renderers. While faster platform renderers are a clear win, you really start to see the big gains using them in combination with a new feature, debuting in 2.5.0, called Layout Compression. Not to be eclipsed by those performance focused boosts, we’re also releasing Forms Embedding in this preview. We’re excited to take these improvements off the pages of our public roadmap and put them into your hands. Read on for details on how you can start benefiting from these fantastic improvements, and much more.

Big Thing 1: Layout Compression

When optimizing a layout for performance, whether for the purpose of smoother animation or speed of rendering, you quickly learn the value of having a flat view hierarchy. Take this page for example:

Source: https://github.com/davidortinau/ProfileLayout

Note: this page is NOT optimized at all. In fact, you can probably point to many things that ought to be changed.


Compound this average layout with the need to create additional container renderers and wrappers for platform renderers, and it results in more views in your view tree than are necessary, approximately 130 for this example.

Consider that performing layout requires child-to-parent recursion for measurement and then layout. The deeper a UI nests (view within view within view), the more iterations are required. Layout Compression allows you to specify unnecessary nesting and allows Xamarin.Forms to opt-out of creating that layout view.

Using Xamarin Inspector we can view the UI layering of this page without Layout Compression or Fast Renderers enabled:

Now enable Fast Renderers in the MainActivity.cs:


And then enable Layout Compression. To enable Layout Compression, identify the layouts (StackLayout, AbsoluteLayout, Grid, RelativeLayout) to compress and add enable it with CompressedLayout.IsHeadless=”true”. For example:


Now take a look at the layout tree layering:

The improvement in these visuals is obvious. I’ll save you some counting to see how much we were able to flatten the UI.

  • Default: 130 Renderers
  • Layout Compression: 111 Renderers
  • Layout Compression + Fast Renderers: 70 Renderers

The question naturally becomes, “how much faster does this make my application?” This will vary depending on the complexity of your view, the version of the operating system you’re using, and the device on which it’s running. While everyone benefits, we expect to see the biggest difference on older devices.

Because layout compression eliminates the renderer for the layout, note that anything you previously expect to be part of that renderer will no longer be present:

  • Background color
  • Gestures
  • Transformations
  • etc.

Layout Compression is available on iOS and Android.

Big Thing 2: Forms Embedding

At Build 2017 we showcased taking a Xamarin.Forms ContentPage and embedding it in native Xamarin.iOS, Xamarin.Android, and UWP applications. Even with that being a very early preview, it didn’t stop many of you from exploring the possibilities. Since then, we’ve been cleaning up the implementation, resolving issues found in our early testing (thank you early adopters!), and validating our use cases for this new capability.

What might you want to do with this?

  • Take an existing Xamarin.Forms page and use it in another Xamarin iOS, Android, or UWP application that doesn’t use Xamarin.Forms.
  • Start a project using Xamarin.Forms for the speed and ease of delivering a prototype, and then migrate it page by page to Xamarin native/
  • Add shared pages to any existing Xamarin application which changing the entire architecture.

And that’s just the beginning. Now there’s no question whether to start with Xamarin.Forms. Use Xamarin.Forms everywhere it’s suitable in your applications!

Big Thing 3: Improved macOS Desktop Support

Xamarin.Forms has grown up in mobile, and extending to desktop paradigms is a process. In Xamarin.Forms 2.4.0, we introduced a preview of macOS support, and I’ve already seen some impressive applications from you. Your feedback has helped identify where we most needed to increase support, so in 2.5.0 you’re getting:

App Exit

From anywhere in your application, you can call Application.Current.Quit() to quit.


Desktop applications can handle menus differently than touch or mobile applications. In this preview, you can now add context menus on right click, as well as attaching menus to the top level of your application so they appear in the top bar on macOS.

For example, below we construct a menu in C# and attach it to a Label in our view. Right clicking the Label will now open the context menu.

Source: https://github.com/davidortinau/weather-app/tree/macos-and-location


Accelerators, also known as key modifiers, allow you to add keyboard shortcuts to activate menu items. In this example, we’re adding the cmd+R accelerator to the refresh menu item.

Then the accelerator is added to a top level menu item, and is available to use from anywhere in the application.

Preview Today!

Xamarin.Forms is available now on NuGet. To update, open your NuGet package manager, enable the Pre-Release option, and update all of your project references.

What’s with the new version numbers?
Our builds are now being generated from Visual Studio Team Services which simply generates a different build number.

Your participation in our pre-releases are essential. Please let us know about any issues you find by filing detailed reports in Bugzilla.

Discuss this post in the forums!

David Ortinau
David Ortinau

Senior Program Manager, Mobile Developer Tools

Follow David   

No Comments.