Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Forms.ListView crashes when ItemSource has item removed and another inserted

BuildCalcBuildCalc USMember ✭✭✭
edited October 2015 in Xamarin.Forms

I am at my whits end - any help would be greatly appreciated. I have a PCL Xamarin.Forms app on iOS and Android. The app runs great on Android but crashes on iOS. To best illustrate the issue, I have included a simplified program (below).

PLEASE NOTE: Crash in second comment (below) is identical to the one I am getting in my full featured application. Please consider it the crash in question.

Description of the program:
- Single view, PCL, iOS and Android
- View is a ListView
- ListView's ItemsSource is a List of at least two Observable Collections (of an object w/ BindableProperties)
- ListView's Grouping is enabled
- ListView uses a dynamic ViewCell as DataTemplate

Environment:
- iOS 8.x and 9.x (device or simulator)
- Xamarin.Forms 1.5.1.6468 (see second comment, below for behavior on 1.5.1.6471)

Actions:
- start program on device or simulator
- make first selection (select a cell in the first group, cell will display the word "pizza")
- make second selection (again, from the first group)

Expected behavior: App will show original contents of first selection at the location of the second selection

Observed behavior: App crashes with the following stack trace: (see second comment, below for different stack trace on 1.5.1.6471)

System.NullReferenceException: Object reference not set to an instance of an object
  at Xamarin.Forms.Platform.iOS.ViewCellRenderer+ViewTableCell.UpdateCell (Xamarin.Forms.ViewCell cell) [0x000f4] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.ViewCellRenderer+ViewTableCell.set_ViewCell (Xamarin.Forms.ViewCell value) [0x0000a] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.ViewCellRenderer.GetCell (Xamarin.Forms.Cell item, UIKit.UITableViewCell reusableCell, UIKit.UITableView tv) [0x0004d] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.CellTableViewCell.GetNativeCell (UIKit.UITableView tableView, Xamarin.Forms.Cell cell) [0x0007e] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.GetCell (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x00008] in <filename unknown>:0
  at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
  at UIKit.UITableView.EndUpdates () [0x00010] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/build/ios/native/UIKit/UITableView.g.cs:297
  at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateItems (System.Collections.Specialized.NotifyCollectionChangedEventArgs e, Int32 section, Boolean resetWhenGrouped) [0x000ef] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnGroupedCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0001e] in <filename unknown>:0
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnInnerCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <filename unknown>:0
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <filename unknown>:0
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, Boolean fixWindows) [0x004fb] in <filename unknown>:0
  at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <filename unknown>:0
  at Xamarin.Forms.ListProxy+<>c__DisplayClassc.<OnCollectionChanged>b__8 () [0x00013] in <filename unknown>:0
  at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x000ae] in <filename unknown>:0
  at Xamarin.Forms.ListProxy+WeakNotifyProxy.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00031] in <filename unknown>:0
  at System.Collections.ObjectModel.ObservableCollection`1[ColorGroupList.App+Item].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00012] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:286
  at System.Collections.ObjectModel.ObservableCollection`1[ColorGroupList.App+Item].OnCollectionChanged (NotifyCollectionChangedAction action, System.Object item, Int32 index) [0x00000] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:349
  at System.Collections.ObjectModel.ObservableCollection`1[ColorGroupList.App+Item].RemoveItem (Int32 index) [0x0002b] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:203
  at System.Collections.ObjectModel.Collection`1[ColorGroupList.App+Item].Remove (ColorGroupList.Item item) [0x0002d] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/objectmodel/collection.cs:134
  at ColorGroupList.App.OnItemSelected (System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) [0x0004e] in /Users/ben/Downloads/xamarin-forms-book-preview-2-master/Chapter19/ColorGroupList/ColorGroupList/ColorGroupList/App.cs:71
  at at (wrapper delegate-invoke) System.EventHandler`1<Xamarin.Forms.SelectedItemChangedEventArgs>:invoke_void_object_TEventArgs (object,Xamarin.Forms.SelectedItemChangedEventArgs)
  at Xamarin.Forms.ListView.OnSelectedItemChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0001c] in <filename unknown>:0
  at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x00112] in <filename unknown>:0
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x00235] in <filename unknown>:0
  at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes) [0x00000] in <filename unknown>:0
  at Xamarin.Forms.ListView.NotifyRowTapped (Int32 groupIndex, Int32 inGroupIndex) [0x00048] in <filename unknown>:0
  at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.RowSelected (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x00041] in <filename unknown>:0
  at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
  at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/UIKit/UIApplication.cs:77
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/UIKit/UIApplication.cs:61
  at ColorGroupList.iOS.Application.Main (System.String[] args) [0x00008] in /Users/ben/Downloads/xamarin-forms-book-preview-2-master/Chapter19/ColorGroupList/ColorGroupList/ColorGroupList.iOS/Main.cs:17

Code:

using System;
using Xamarin.Forms;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace ColorGroupList
{
    public class App : Application
    {
        public class Item : BindableObject {
        }

        public class Item<T> : Item {
            public static BindableProperty ValueProperty = BindableProperty.Create ("Value", typeof(T), typeof(Item<T>), default(T));
            public T Value {
                get { return (T)GetValue (ValueProperty); }
                set { SetValue (ValueProperty, value); }
            }
        }

        public class ItemGroup : ObservableCollection<Item> {
            public string Title;
        }

        List<ItemGroup> groups;
        ItemGroup strings, booleans;
        ListView listView;

        public App()
        {
            groups = new List<ItemGroup> ();

            strings = new ItemGroup () { Title = "Strings" };
            for (int i = 0; i < 10; i++)
                strings.Add (new Item<string> () { Value = "strings[" + i + "]"} );
            groups.Add (strings); 


            booleans = new ItemGroup () { Title = "Booleans" };
            for (int i = 0; i < 10; i++)
                booleans.Add (new Item<bool> () { Value = i%2==1 });
            groups.Add (booleans);

            listView = new ListView () {
                ItemsSource = groups,
                ItemTemplate = new DataTemplate (typeof(DynamicCell)),
                IsGroupingEnabled = true,
                HasUnevenRows = true,
            };
            listView.ItemSelected += OnItemSelected;

            MainPage = new ContentPage () {
                Content = listView,
                Padding = new Thickness(0,20,0,0),
            };
        }

        Item lastItem = new Item<string>() { Value = "pizza" };
        public void OnItemSelected(object sender, SelectedItemChangedEventArgs e) {
            listView.SelectedItem = null;
            var item = e.SelectedItem as Item;
            foreach (ItemGroup group in groups) {
                if (group.Contains (item)) {
                    int index = group.IndexOf (item);
                    var tmpItem = item;
                    group.Remove (item);
                    group.Insert (index, lastItem);
                    System.Diagnostics.Debug.WriteLine ("removed:" + item + " for:" + lastItem);
                    lastItem = tmpItem;
                    return;
                }
            }
        }

        public class HeaderCell : ViewCell {
            public HeaderCell() {
                View = new Label { TextColor = Color.White, BackgroundColor = Color.Blue, HeightRequest=25 };
            }
            protected override void OnBindingContextChanged() {
                base.OnBindingContextChanged ();
                ((Label)View).Text = ((ItemGroup)BindingContext).Title;
            }
        }

        public class DynamicCell : ViewCell {
            protected override void OnBindingContextChanged() {
                base.OnBindingContextChanged ();

                Type type = BindingContext.GetType ();
                if (type == typeof(Item))
                    View = new BoxView () { BackgroundColor = Color.Gray };
                else if (type == typeof(Item<string>)) {
                    View = new Label ();
                    View.BindingContext = BindingContext;
                    View.SetBinding (Label.TextProperty, "Value");
                } else if (type==typeof(Item<bool>)) {
                    View = new Switch ();
                    View.BindingContext = BindingContext;
                    View.SetBinding (Switch.IsToggledProperty, "Value");
                }
                View.HeightRequest = 56;
            }
        }
    }
}

Special notes:
- Does not crash on Android
- If only one view group is shown, the app does not crash
- If the dynamic behavior of DynamicCell is removed (see below), the app does not crash

public class DynamicCell : ViewCell { protected override void OnBindingContextChanged() { base.OnBindingContextChanged (); View = new Label (); View.BindingContext = BindingContext; View.SetBinding (Label.TextProperty, "Value"); } }

Best Answer

Answers

  • BuildCalcBuildCalc USMember ✭✭✭
    edited October 2015

    (comment removed because it was not relevant)

  • BuildCalcBuildCalc USMember ✭✭✭
    edited October 2015

    Just updated to Xamarin.Forms 1.5.1.6471 and there are some small changes in behavior (no improvement, though). Specifically:

    First, DynamicCell had to be updated to account for Unhooking of the removed cell:

            public class DynamicCell : ViewCell {
                protected override void OnBindingContextChanged() {
                    base.OnBindingContextChanged ();
                    Type type = BindingContext?.GetType ();
    
                    if (type==null || type == typeof(Item))
                        View = new BoxView () { BackgroundColor = Color.Gray };
                    else if (type == typeof(Item<string>)) {
                        View = new Label ();
                        View.BindingContext = BindingContext;
                        View.SetBinding (Label.TextProperty, "Value");
                    } else if (type==typeof(Item<bool>)) {
                        View = new Switch ();
                        View.BindingContext = BindingContext;
                        View.SetBinding (Switch.IsToggledProperty, "Value");
                    }
                    View.HeightRequest = 56;
                }
            }
    

    Second, scroll to have cell "strings[7]" in the middle of the screen. Click twice and the stack trace is now:

    System.NullReferenceException: Object reference not set to an instance of an object
      at Xamarin.Forms.Platform.iOS.ViewCellRenderer+ViewTableCell.SizeThatFits (CGSize size) [0x00056] in <filename unknown>:0
      at at (wrapper managed-to-native) ObjCRuntime.Messaging:void_objc_msgSend (intptr,intptr)
      at UIKit.UITableView.EndUpdates () [0x00010] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/build/ios/native/UIKit/UITableView.g.cs:297
      at Xamarin.Forms.Platform.iOS.ListViewRenderer.UpdateItems (System.Collections.Specialized.NotifyCollectionChangedEventArgs e, Int32 section, Boolean resetWhenGrouped) [0x000a2] in <filename unknown>:0
      at Xamarin.Forms.Platform.iOS.ListViewRenderer.OnGroupedCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0001e] in <filename unknown>:0
      at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnInnerCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <filename unknown>:0
      at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <filename unknown>:0
      at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, Boolean fixWindows) [0x0049f] in <filename unknown>:0
      at Xamarin.Forms.TemplatedItemsList`2[Xamarin.Forms.ItemsView`1[Xamarin.Forms.Cell],Xamarin.Forms.Cell].OnProxyCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00000] in <filename unknown>:0
      at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x0000a] in <filename unknown>:0
      at Xamarin.Forms.ListProxy+<>c__DisplayClass52_0.<OnCollectionChanged>b__0 () [0x00018] in <filename unknown>:0
      at Xamarin.Forms.ListProxy.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x000a0] in <filename unknown>:0
      at Xamarin.Forms.ListProxy+WeakNotifyProxy.OnCollectionChanged (System.Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00031] in <filename unknown>:0
      at System.Collections.ObjectModel.ObservableCollection`1[CellDelete.App+Item].OnCollectionChanged (System.Collections.Specialized.NotifyCollectionChangedEventArgs e) [0x00012] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:286
      at System.Collections.ObjectModel.ObservableCollection`1[CellDelete.App+Item].OnCollectionChanged (NotifyCollectionChangedAction action, System.Object item, Int32 index) [0x00000] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:349
      at System.Collections.ObjectModel.ObservableCollection`1[CellDelete.App+Item].InsertItem (Int32 index, CellDelete.Item item) [0x00024] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/System/compmod/system/collections/objectmodel/observablecollection.cs:217
      at System.Collections.ObjectModel.Collection`1[CellDelete.App+Item].Insert (Int32 index, CellDelete.Item item) [0x00038] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/_build/Library/Frameworks/Xamarin.iOS.framework/Versions/git/src/mono/external/referencesource/mscorlib/system/collections/objectmodel/collection.cs:124
      at CellDelete.App.OnItemSelected (System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) [0x0005c] in /Users/ben/Development/Xamarin/CellDelete/CellDelete/CellDelete.cs:67
      at at (wrapper delegate-invoke) System.EventHandler`1<Xamarin.Forms.SelectedItemChangedEventArgs>:invoke_void_object_TEventArgs (object,Xamarin.Forms.SelectedItemChangedEventArgs)
      at Xamarin.Forms.ListView.OnSelectedItemChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0001c] in <filename unknown>:0
      at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0
      at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0
      at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes) [0x00000] in <filename unknown>:0
      at Xamarin.Forms.ListView.NotifyRowTapped (Int32 groupIndex, Int32 inGroupIndex) [0x00048] in <filename unknown>:0
      at Xamarin.Forms.Platform.iOS.ListViewRenderer+ListViewDataSource.RowSelected (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x00038] in <filename unknown>:0
      at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
      at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/UIKit/UIApplication.cs:77
      at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/2320/1f068b49/source/maccore/src/UIKit/UIApplication.cs:61
      at CellDelete.iOS.Application.Main (System.String[] args) [0x00008] in /Users/ben/Development/Xamarin/CellDelete/iOS/Main.cs:17
    
    
    
  • Hey,

    Not certain if this is relevant or not, but I had the same error when updating a custom List View in iOS.

    I found this bug, https://bugzilla.xamarin.com/show_bug.cgi?id=24334, and implemented a similar fix (updated to work with the newer Xamarin Forms implementation. I haven't gotten the error again, but it was kind of hard to reproduce in the first place.

    // Workaround: Seems to require this override in this custom renderer class to prevent the bug below. // https://bugzilla.xamarin.com/show_bug.cgi?id=24334 public override CGSize SizeThatFits(CGSize size) { if (Control != null) { return base.SizeThatFits(size); } return CGSize.Empty; }

  • BuildCalcBuildCalc USMember ✭✭✭
    edited November 2015

    Aaron - How I wished that would work. No custom renderers were used in this project (it's 100% stock Xamarin.Forms). With that being said, your suggestion was interesting enough for me to spend a hour of so investigating it. What I learned was that the offending SizeThatFits method is part of the nested class ViewTableCell. ViewTableCell is nested in ViewCellRenderer and unfortunately has internal access. My C# foo is about brown belt, so I'm not aware of a way to override an internal method that is buried that deep.

    I also thought "why don't I just make my own renderer!" using Xamarin's source via the assembly browser. What I discovered is that it is littered with internal properties, methods and classes. I could use reflection to get around most of it (creating extremely brittle code) but not all of it.

    Lastly, please let me know if I'm not thinking about this correctly. When it comes to thinking I've painted myself in a corner, I really like being shown how I'm wrong.

  • BuildCalcBuildCalc USMember ✭✭✭

    FYI: Xamarin support has filed this as a bug: https://bugzilla.xamarin.com/show_bug.cgi?id=35499

  • BuildCalcBuildCalc USMember ✭✭✭

    Aaron - You've given me something to think about. I'll take a closer look once I complete the current rabbit hole I'm traversing.

  • JamieBenJamieBen USMember

    Hi Ben, I'm working on the same issue with you right now.
    In my project, I put a "MORE" button in the listview.footer which let us loading more data.
    When I click "MORE", App Crashed in IOS but work fine in Android.
    I wonder have you solve the problem yet?
    Appreciate for your any advice.

  • BuildCalcBuildCalc USMember ✭✭✭

    @JamieBen ,

    No, I've been off working on addressing other gaps in Forms that I need for my project (see http://Forms9Patch.com to see what I mean). In the process of filling these gaps, I believe I have learned enough about how Forms works under the covers to build the ListView I really need (one with built-in drag-n-drop capability). Since I know where Xamarin's bug is (they just haven't gotten around to fixing it), I can be sure the one I build won't have it.

    Ben

  • JamieBenJamieBen USMember

    OK, I see.
    I'll keep working on it.
    Thanks anyway.

  • sachinkanadiasachinkanadia GBMember ✭✭

    I have the same issue with a databound collection of a carousel view. When manipulating the itemSource collection I get an object instance error. Here's the link - https://forums.xamarin.com/discussion/68400/object-instance-exception-thrown-when-bound-collection-of-carousel-view-is-cleared#latest.

    Is this a genuine bug with Xamarin or is this something that Xamarin cannot support? - The manipulation of the ItemSource property? Or is there something I'm doing wrong ?!?

  • JohnHardmanJohnHardman GBUniversity admin

    @BuildCalc @AaronWinterhoff

    I am using XF 2.3.1.114 and am hitting a null reference in SizeThatFits on iOS. I don't have a custom ViewCellRenderer - this is the basic XF ViewCellRenderer. I only hit this when using RecycleElement as the caching strategy. I am just scrolling through a list, not deleting anything. Has anybody else hit this particular scenario and found a solution? I'll try adding a custom renderer with an override tomorrow, in the hope that might identify the cause so that Xamarin can fix the underlying problem.

    0x56 in Xamarin.Forms.Platform.iOS.ViewCellRenderer.ViewTableCell.SizeThatFits at C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.iOS\Cells\ViewCellRenderer.cs:123,5 C#
    0x7 in Xamarin.Forms.Platform.iOS.ContextActionsCell.SizeThatFits at C:\BuildAgent\work\aad494dc9bc9783\Xamarin.Forms.Platform.iOS\ContextActionCell.cs:129,4   C#
    0xFFFFFFFFFFFFFFFF in UIKit.UIApplication.UIApplicationMain C#
    0xB in UIKit.UIApplication.Main at /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/UIKit/UIApplication.cs:79,-1  C#
    0x37 in UIKit.UIApplication.Main at /Users/builder/data/lanes/3339/39ebb778/source/maccore/src/UIKit/UIApplication.cs:62,-1 C#
    

    0xE in KaekwondoNamespace.iOS.Application.Main at G:\tfs\Kaekwondo\ProjectMarvinPrototype\Kaekwondo.iOS\Main.cs:24,13 C#

  • JohnHardmanJohnHardman GBUniversity admin

    Identified the cause - in an attempt to resolve other issues I followed an example I found in the forums where all View creation was done inside OnBindingContextChanged instead of in the ViewCell constructor. XF on iOS doesn't like that.

Sign In or Register to comment.