Xamarin.Forms Stable Comes to .NET Standard 2.0

David Ortinau

Today, we are thrilled to share our latest stable release of Xamarin.Forms, version 2.4.0. This is our fastest, most stable release ever and we think you’re going to love it!

Xamarin.Forms 2.4.0 Highlights

You’ll recognize many of these highlights as shared in our public roadmap, in addition to more than 150 bug fixes.

  • .NET Standard 2.0 Support
  • New Feature Flags API
  • Android Fast Renderers: Button, Image, Label
  • macOS Preview

A huge thanks to the more than 20 amazing community members that contributed to making this a fantastic release.

.NET Standard 2.0 Support

As support begins to take off for .NET Standard 2.0, we have made sure Xamarin.Forms works seamlessly with both the standard and existing PCL profiles. To get started with .NET Standard and Xamarin.Forms, you can create a new .NET Standard Library project.

Next, add the Xamarin.Forms 2.4.0 NuGet dependency so you’re ready to start adding your Xamarin.Forms project files. Before you go too far, though, be sure to read the important release notes.

New Feature Flags API

We are introducing a new API to enable or disable features by setting a feature flag just before initializing Xamarin.Forms. This will enable you to benefit from features or behaviors that may be of high value to you without introducing changes that you may not want. As of 2.4.0, the Fast Renderers for Android are the first feature to take advantage of this.

To enable Fast Renderers on Android:

public partial class Activity1 : FormsAppCompatActivity
{
    protected override void OnCreate(Bundle bundle)
    {
                ...
                Forms.SetFlags("FastRenderers_Experimental");
                Forms.Init(this, bundle);
                ...
    }
}

Android Fast Renderers

Fast Renderers are a refactoring of the renderer architecture to optimize for performance and memory consumption. In the original renderer design, a wrapper class is used for convenience to expose the renderer API. This has the side effect of an additional UI element wrapping each and every native UI element.

You can see an example UI hierarchy that is generated without Fast Renderers in the diagram below.

Now take a look at the UI hierarchy after we remove the need for that wrapping element.

I’ll save you some counting; we were able to reduce the number of UI elements from 19 to 13! The net result is a faster, more memory-responsible UI.

We’re shipping Fast Renderers on Android for Button, Image, and Label controls in 2.4.0, and we’ll continue to work on shipping more of these for Android as well as other platforms going forward.

Due to the changes necessary to make this happen, and the likelihood of the API changing while we work on additional controls, these classes are currently sealed and opt-in via the aforementioned Feature Flags API. We’ll expose the classes and consider enabling them by default once we’ve finalized the API.

macOS Preview

As I blogged previously, Xamarin.Forms macOS is available in preview! We’ve made several bug fixes in 2.4.0 to the work that was introduced during the pre-release cycle. Now you can easily extend your Xamarin.Forms applications to macOS.

If you author a 3rd party library or component for Xamarin.Forms, now is the time to make sure it’s compatible with macOS projects.

Let us know in the forum discussion what you think about this preview, show us what you’re working on, and help us identify what we need to do to improve macOS for a stable release.

Update Today

This release is available today via NuGet. Be sure to review the full release notes and, as usual, when upgrading an existing solution, update all projects in your solution that reference Xamarin.Forms.

Discuss this post on the Xamarin Forums.

0 comments

Discussion is closed.

Feedback usabilla icon