Make Your Xamarin.Forms Apps Even Better (and Faster!)

David Ortinau

As we continue to pursue the best in stability and performance, we’re excited to get your feedback on our first pre-release of Xamarin.Forms 2.3.5. Boasting over 130 fixes and enhancements this release, I’d like to highlight a few that we’re most eager for you to explore: Fast Renderers, ListView enhancements, and macOS preview!

Fast Renderers for Android

The concept behind Fast Renderers is fairly simple: reduce inflation and rendering costs by flattening the control nesting. Simple almost always performs better! We’re delivering Button, Image, and Label in this first batch of optimized renderers. To use it, do nothing; they’re on by default in this pre-release.

Our initial testing teases upwards of 2x speed improvement to render a view with these controls. Large ListView scrolling with cells of these controls was visibly smoother and recovered much faster when aggressively scrolling thousands of rows. What’s clear, and is no real surprise, is that hardware, OS version, and the complexity of the view are significant factors in how greatly this will impact your results.

Join our performance discussion in the forums and let us know your results. We’re also asking for XAML layout contributions to build up our performance test suite. We’d love your participation!

We have more work to do performing this refactoring on the remaining controls for Android and iOS, but we’re excited to share what we have so far.

ListView Enhancements

We continue to chip away at improving list performance. Fast Scroll on Android is now enabled by default and may be set using a Platform Specific.

listView.On<Android>().SetIsFastScrollEnabled(true);

If you’re using a shared project like I am and have a namespace collision with Android, this is a clean way to address that:

using Platform = Xamarin.Forms.PlatformConfiguration;
...
listView.On<Platform::Android>().SetIsFastScrollEnabled(true);

And with FastScrollEnabled you can now use Section Indexes.

Android isn’t the only beneficiary of ListView love. iOS and UWP get over a dozen updates and fixes to address performance, recycling, and reported memory leaks.

macOS Preview

We know many have been following our macOS backend for Xamarin.Forms progress and building from that public branch. Today, we hope everyone will give this preview a run and provide your feedback. Here are the basics of what you need to get started:

  1. Add a Mac Cocoa App project to your Xamarin.Forms solution and set it as your Startup Project
  2. Add a project reference to your shared project or PCL
  3. Import any platform specific resources such as images or fonts
  4. Add this pre-release NuGet to all projects and PCLs
  5. Update the AppDelegate.cs
  6. Run it!

Here’s a template AppDelegate.cs to give you a jump start:

[Register("AppDelegate")]
public class AppDelegate : FormsApplicationDelegate
{
	NSWindow _window;
	public AppDelegate()
	{
		var style = NSWindowStyle.Closable | NSWindowStyle.Resizable | NSWindowStyle.Titled;

		var rect = new CoreGraphics.CGRect(200, 1000, 1024, 768);
		_window = new NSWindow(rect, style, NSBackingStore.Buffered, false);
		_window.Title = "Xamarin.Forms Mac";
		_window.TitleVisibility = NSWindowTitleVisibility.Hidden;
	}

	public override NSWindow MainWindow
	{
		get { return _window; }
	}

	public override void DidFinishLaunching(NSNotification notification)
	{
		Forms.Init();
		LoadApplication(new App());

		base.DidFinishLaunching(notification);
	}
}

Try It Today!

To get Xamarin.Forms 2.3.5.233-pre1, search your NuGet package manager with the pre-release option enabled, and install it into each PCL and App project.

Be sure to check the full release notes, and to see what else is in the Xamarin.Forms pipeline visit the public roadmap.

If you have a bug to report, drop us a detailed report here so we can investigate.

Discuss this post on the Xamarin Forums

0 comments

Discussion is closed.

Feedback usabilla icon