Xamarin.Forms 1.5.2-pre1

Important Notes

This release is more alpha than most pre-releases. We want to get as much testing on the new optimization work as possible. Expect to see changes and more work landing into this release before promotion to stable.

Enhancements

New properties

These all do pretty much what you expect

  • Editor.TextColor
  • Entry.TextColor
  • Editor.FontSize
  • Editor.FontAttributes
  • Editor.FontFamily

New API

public enum ListViewCachingStrategy
{
    RetainElement = 0,
    RecycleElement,
}

This new enum is used in conjuction with a new constructor for ListView, ListView (ListViewCachingStrategy cachingStrategy). The default mode, RetainElement represents the old ListView behavior. It is also the default behavior if the old constructor is retained. The new behavior has the following characteristics.

  • Only works on Android/iOS. Windows will simply get the old behavior no matter what.
  • DataTemplate will be inflated to match as many native renderers for the cells are created.
  • During virtualization, the Cell will have its binding context updated.

This means if an App opt into the new mode, the app must appropriately handle BindingContext updates. All data about the cell must come from the binding context or consistency errors may occur. If the cells are using custom renderers, it must ensure they properly implement property change notification. This mode is not always a pure performance win, testing is the only way to know for sure, however there are some basic guidelines:

  • Use RecycleElement if:
    • Cell BindingContext defines all properties/data about the View
    • Cells are largely similar and do not morphe dramatically based on BindingContext
    • The Cell has a moderate to small number of bindings
    • The Cell adheres well to the new performance guidelines below
  • Use RetainElement if:
    • Cells morph frequently
    • Cells have large numbers of bindings (20 to 30 tends to be the crossover point)
    • When testing RecycleElement, it is slower

Generally speaking, prefer RecycleElement as it can offer significant performance gains when in the fast path scenario. Eventually RetainElement may be phased out, however this will only happen once RetainElement no longer offers any performance advantage in any scenario.

Layout Optimization

There is a new experimental layout optimization in this release of Xamarin.Forms. The optimization is complex and currently only impacts layout updates. Effectively the optimization serves to block InvalidateMeasure call chains. To get the best possible performance follow these performance guidelines:

  • Leave the View.VerticalOptions and View.HorizontalOptions alone as much as possible. The default value of Fill or FillAndExpand allows for the best layout optimization.
  • When using a StackLayout, make sure to have only one child set to Expand.
  • Avoid RelativeLayout when possible.
  • When using Grid, avoid Auto rows/columns if possible. Fixed row/cols are best. Stars are equally good if parent tree follows guidelines.
  • When using AbsoluteLayout, avoid using AutoSize if possible.
  • When using Labels, set the LineBreakMode to NoWrap whenever possible.

This optimization may impact the layout of your app. If you experience any differences at all, please report them as bugs. Further the optimization will work with the new ListView caching strategy, effectively doubling down on scrolling performance.

Bug Fixes

Bug 34632 - Can't change IsPresented when setting SplitOnLandscape Bug 34556 - Minimum version determination methods on iOS will fail once iOS hits version 10 Bug 34549 - Setting a BindableProperty of Type DateTime? to null raises Error Bug 34235 - Xamarin.Forms.Platform.WinRT.TabbedPageRenderer OnElementChanged not virtual Bug 34061 - RelativeLayout - First child added after page display does not appear Bug 34007 - Z order drawing of children views are different on Android and iOS Bug 33764 - Frame outline colour doesn't change using ViewModel Bug 33612 - Removing a page from the navigation stack causes an 'Object reference' exception in Android only Bug 33499 - Android WebViewRenderer doesn't unhook events properly Bug 32902 - [iOS | iPad] App Crashes (without debug log) when Master Detail isPresented and navigation being popped Bug 32801 - Memory Leak in TabbedPage + NavigationPage Bug 32447 - [iOS] App crash when scrolling quickly through a TableView that has Pickers in the cells. Bug 32040 - EntryCell.Tapped or SwitchCell.Tapped does not fire when within a TableView Bug 31366 - Pushing and then popping a page modally cause ArgumentOutOfRangeException Bug 29257 - CarouselPage.CurrentPage Does Not Work Properly When Used Inside a NavigationPage

Other Fixes

  • [A] Non-AppCompat backend no longer fails to redraw Frame correctly
  • OnPlatform now passing the Windows value to WinRT projects. This API is being considered for replacement with something more extensible.
  • OpenGLView now uses IOpenGLViewController for backend communication

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.