Xamarin.Forms 1.5.2-pre2 Released

TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai
edited November 2015 in Xamarin.Forms

pre-2 Notes


  • Entry.HorizontalTextAlignment
  • SearchBar.FontAttributes, FontFamily, FontSize
  • XAlign properties renamed HorizontalTextAlignment
  • YAlign properties renamed VerticalTextAlignment
  • Add PinchGestureRecognizer

Bug Fixes

  • [iOS] Resolve issue where scroll to top when tapping Status Bar sometimes wouldn't work
  • [Win] Fix issue where page sometimes would load blank when used with IsVisible
  • Resolve issue where SearchBar would reset keyboard status sometimes
  • XamlC support flags as enums now
  • Resolve compatibility issue with iOS7 and PreservesSuperviewLayoutMargins
  • Fix issue with StackLayout optimization
  • UWP CancelColor now supported on SearchBar
  • Forms.Init only requires IActivatedEventArgs on windows now

pre-1 Notes

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.


New properties

These all do pretty much what you expect

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


public enum ListViewCachingStrategy 
    RetainElement = 0,

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


  • TektonTekton USMember ✭✭✭

    Oh it's a brave new world. :blush:

  • FranciscoGGFranciscoGG ESMember ✭✭

    It seems reeeeally nice :)

  • AdamPAdamP AUUniversity ✭✭✭✭✭

    Exciting update, especially with the cell recycling. Too bad about Windows Phone though. Is that planned for an upcoming release?

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    Unfortunately it's just not something you can easily target on the windows platforms due to the way their listviews work. You don't really get control over virtualization the way you do on iOS/Android.

    We MIGHT try doing our own panel at some point so we could do this, but I dont know that this would get very high on the priority queue.

  • JKayJKay USMember ✭✭✭
    edited October 2015

    just a quick question regarding the layout optimisation. Which of these two points takes precedence?

    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.

    Do I leave the children of a stacklayouts LayoutOptions alone or do I change them to be Fill?

    Other than that... this release looks like a GREAT addition to Xamarin.Forms!

  • voidvoid DKBeta ✭✭✭

    RecycleElement ? Oh mamma!

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @JKay the default values will be Fill. Some things default to FillAndExapand (listviews/tableviews/etc). You want only one thing to have the expand flag set in your stacklayout, everything else should ideally be Fill (which is the default).

  • JKayJKay USMember ✭✭✭

    @TheRealJasonSmith OK Great. Thanks Jason

  • GeorgeCookGeorgeCook PEUniversity ✭✭✭

    Glad to see this make it's way into the code at long last (and not a mention of xamlc, either - hell hath frozen over).

    Can't wait to try it out. @TheRealJasonSmith Have you guys got any performance benchmarks, do you guys now support variable sized cells? Does this solution support headers?

  • nemephxnemephx USMember

    @TheRealJasonSmith Thanks for the new additions. Adding to the WP discussion, what is the level of WP support with XForms? Is RT 100% supported as in it's encouraged for customers to make 8.1 store apps? How will UWP fit into the picture?

  • VictorHGarciaVictorHGarcia USUniversity ✭✭

    @TheRealJasonSmith what are the probabilities to add Entry.PlaceHolderTextColor Property and also Editor.PlaceHolderTextColor ? This will save tons of lines to perform a custom render just for this property.

    Thanks in advance!

  • AnthonyRamirezAnthonyRamirez USUniversity ✭✭✭

    LOVING these bug fix releases!!! :smiley: X.Forms is getting better and better

    Thanks very much for the hard work. It's greatly appreciated. :smiley:

  • thaihung203thaihung203 USMember

    Wow, it's now 1AM here, but can't wait to try

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @VictorHGarcia they will be coming in this release. I wanted to get the layout perf work being tested ASAP. Those features are being done as we speak however were not ready for release.

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @GeorgeCook I hacked this together so you can see the performance differences. This is not 100% a real world test, it is kind of a horrible worst case.

    public class LayoutPerformanceGallery : ContentPage
            public LayoutPerformanceGallery ()
                int size = 3;
                var grid = new Grid {
                    VerticalOptions = LayoutOptions.FillAndExpand,
                    RowDefinitions = {
                        new RowDefinition { Height = new GridLength (100, GridUnitType.Absolute) },
                        new RowDefinition { Height = new GridLength (5, GridUnitType.Star) },
                        new RowDefinition { Height = new GridLength (7, GridUnitType.Star) },
                    ColumnDefinitions = {
                        new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
                        new ColumnDefinition { Width = new GridLength (100, GridUnitType.Absolute) },
                        new ColumnDefinition { Width = new GridLength (7, GridUnitType.Star) },
                for (int i = 0; i < size; i++) {
                    for (int j = 0; j < size; j++) {
                        var g = new Grid {
                            RowDefinitions = {
                                new RowDefinition { Height = new GridLength (100, GridUnitType.Absolute) },
                                new RowDefinition { Height = new GridLength (5, GridUnitType.Star) },
                                new RowDefinition { Height = new GridLength (7, GridUnitType.Star) },
                            ColumnDefinitions = {
                                new ColumnDefinition { Width = new GridLength (3, GridUnitType.Star) },
                                new ColumnDefinition { Width = new GridLength (100, GridUnitType.Absolute) },
                                new ColumnDefinition { Width = new GridLength (7, GridUnitType.Star) },
                        for (int k = 0; k < size; k++) {
                            for (int l = 0; l < size; l++) {
                                var label = new Label { Text = "10" };
                                g.Children.Add (label, k, l);
                                labelList.Add (label);
                        grid.Children.Add (g, i, j);
                Content = new StackLayout {
                    Children = {
                        (mainLabel = new Label ()),
            private Label mainLabel = null;
            List<Label> labelList = new List<Label> ();
            Stopwatch sw = new Stopwatch ();
            long ticks = 0;
            int count = 0;
            int cycle = 0;
            bool flip = true;
            Random r = new Random (34269027);
            bool repeat = false;
            protected override void OnAppearing ()
                base.OnAppearing ();
                repeat = true;
                Device.StartTimer (TimeSpan.FromMilliseconds (10), () => {
                    sw.Start ();
                    foreach (var label in labelList) {
                        if (flip) {
                            label.Text = r.Next (10, 40).ToString ();
                        } else {
                            label.Text = r.Next (50, 90).ToString ();
                    sw.Stop ();
                    ticks += sw.ElapsedMilliseconds;
                    sw.Reset ();
                    cycle = (cycle + 1) % 100;
                    if (cycle == 0) {
                        mainLabel.Text = string.Format ("Avg Time: {0:0.000}ms", ticks / (double)count);
                    flip = !flip;
                    return repeat;
            protected override void OnDisappearing ()
                repeat = false;
                ticks = 0;
                count = 0;
                cycle = 0;
                base.OnDisappearing ();
  • AdamPAdamP AUUniversity ✭✭✭✭✭

    thanks @TheRealJasonSmith. While I understand it would be low priority to do anything with Silverlight since its basically sunsetting, do you have plans for RT?

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    We might reconsider if there is enough (positive) push from the community to do it.

  • JKayJKay USMember ✭✭✭
    edited October 2015

    Is there any way to set the ListViewCachingStrategy on a ListView through a property.
    i.e. if I write my ListView in xaml I can't set the ListViewCachingStrategy?

    Am I right in thinking this can only be set in code behind through the constructor of a new ListView?

    My current workaround for this incase anyone else finds themselves in a similar position is to override ListView like so:

        public class NewListView : ListView
            public NewListView() : base(ListViewCachingStrategy.RecycleElement)

    and then use it in xaml like:


    and I would like to report that initial testing shows the improvement to listview performance is huge!

  • JKayJKay USMember ✭✭✭
    edited October 2015

    @TheRealJasonSmith I couldnt see CachingStrategy as a property of ListView in the metadata which is what threw me.

    In addition to this; adding the CachingStrategy="RecycleElement" property to a ListView doesn't improve the performance as much as my ListView override does, so my suspicion is that it isn't applied.
    Am i doing something wrong?

    Actually that does seem to work. Thanks

  • RaphaelSchindlerRaphaelSchindler USMember ✭✭✭

    @TheRealJasonSmith The new improvements for ListView is really great. Thanks for that.

    However Bug 26233 is still not resolved. On my part it doesn't render the Cells when I use a Custom ViewCell where the View is a Frame. At least it doesn't throw an exception anymore.

    I added 2 Videos where I show my problems. First one is with the ViewCell not getting rendered and the second one is for the ScrollTo bug. I further added the ViewCell code. All of this stuff is working on Android and iOS.

    And here's the ScrollTo code:

    private void ArrowDownOnClicked(object sender, EventArgs eventArgs)
        var target = DataView.CalculatedValues[DataView.CalculatedValues.Count - 1];
        ListedViewModel.ListValuesListView.ScrollTo(target, ScrollToPosition.End, false);
    private void ArrowUpOnClicked(object sender, EventArgs eventArgs)
        var target = DataView.CalculatedValues[0];
        ListedViewModel.ListValuesListView.ScrollTo(target, ScrollToPosition.Start, false);
    private void ArrowPensionOnClicked(object sender, EventArgs eventArgs)
        var target = new CalculatedValues();
        foreach (var values in DataView.CalculatedValues.Where(values => values.Age == DataView.InputValuesClass.PensionAge))
            target = values;
        ListedViewModel.ListValuesListView.ScrollTo(target, ScrollToPosition.Center, false);
  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    The example of @TheRealJasonSmith ist nice, but much nicer would be, to post the results here (e.g. 1.5.1 vs 1.5.2-pre1 and/or 1.4.4 vs 1.5.2-pre1) and... this also can be another (own, maybe peruvian) benchmark :smirk:

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    I dont wnat to post results, they will depend on your app and you exact situation. I dont want to mislead people. Some people will see 100x speedups, some will see 0x, most will see something in between.

  • AndresCastroAndresCastro USMember

    @TheRealJasonSmith This made a huge difference on one of my apps. Keep up the good work over there.

  • SoerntPoppeSoerntPoppe DEUniversity ✭✭


    We might reconsider if there is enough (positive) push from the community to do it.

    +1 For a Windows Phone implementation.

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    I'ts clear that the performance benefit will depend on the app. :smirk:
    Therefore, I have mentioned George to do a practical test.
    It further would be nice, if other users would post their practical findings here in an absolute metric (e.g. the largest ListView in my App is showed now in 1 second, where it has took 2 seconds before).
    Can you please specify "huge difference on one of my apps".
    What does this means in numbers (about ??% faster / seconds before / after)?
    And... +2 to Windows Phone implementation (as it is part of .Forms)

  • JKayJKay USMember ✭✭✭

    @FredyWenger Why don't you branch your own project and upgrade to the pre release version and test it for yourself?

    My tests showed a huge performance boost to lists on android, although I can't give you exact numbers

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    Thanks for you posting :smile:
    I don't update my project yet, as the app's for all three platforms are already in the stores and working now (what has cost me extremely time and nerves - especially for WP) and we have started a huge advertising right now.
    The production app's are based on 1.4.4 "stable" so... I want to be able to react fast, if we see some problems.
    But it would be interesting for all users to see here some real findings...

  • RaphaelSchindlerRaphaelSchindler USMember ✭✭✭

    @FredyWenger I can give you some numbers :smile:

    When drawing 60+ items with a rather complex ViewCell it now takes 0.4s on Android where it took 1.7s before. So yes that is a huge performance boost.

    Also +1 on WinPhone implementation

  • FredyWengerFredyWenger CHInsider ✭✭✭✭✭

    @RaphaelSchindler: Thanks - this is a real statement :smiley:

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @RaphaelSchindler show me your ViewCell, I will help you optimize it further. 425% perf boost is respectable here, but we can do better.

  • RaphaelSchindlerRaphaelSchindler USMember ✭✭✭

    @TheRealJasonSmith Its the ViewCell code I posted in the other comment for the WinPhone bug :smile:

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @RaphaelSchindler huh that should be doing better than .4s What device are you using? ListView row heights are uneven?

  • RaphaelSchindlerRaphaelSchindler USMember ✭✭✭

    @TheRealJasonSmith Samsung Galaxy Note 2 (bad OpenGL implementation...) and Gigaset QV1030 (Nvidia Tegra Chip) Yes HasUnevenRows = true is set.

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    @RaphaelSchindler huh... I will need to grab one of them phones and see wtf is up

  • DarkwingDuckDarkwingDuck USMember ✭✭

    In iOS when showing a CarouselPage from a ContentPage which is inside a TabbedPage the pages of the CarouselPage have a wrong height. It seems like the height of the tab bar isn't considered.

    I attached a project to demonstrate the issue.

  • TheRealJasonSmithTheRealJasonSmith USXamarin Team Xamurai

    Okay I see the issue, are you sure this is new or just reporting on the forum?

  • DarkwingDuckDarkwingDuck USMember ✭✭

    Awesome, thank you very much!

  • DarkwingDuckDarkwingDuck USMember ✭✭

    Two problems with XamlC:

    1. It seems like it doesn't work with combined flags.
      I'm using AbsoluteLayout.LayoutFlags="PositionProportional,WidthProportional" and I get the error "Enum value not found for PositionProportional,WidthProportional". See the attached file.

    2. I get the error "The given key was not present in the dictionary" for every TabbedPage.
      You can repreduce this by turning on XamlC in the project I posted earlier about the height problem with CarouselPages.

Sign In or Register to comment.