我有一个列表,里面有一些用户选择的项目。我的CustumCellViewTemplate有一个"unselect“控件,用于从列表中删除单元格。当列表完全被项目填满时,“取消选择”控件可以工作,但是当我想要删除最后一项或者如果最后一项出现在ListView中时,我会得到这样的异常:
"System.NullReferenceException: Object reference not set to an instance of an object.
at Xamarin.Forms.Platform.Android.ListViewAdapter.IsEnabled (System.Int32 position) [0x0002a] in D:\a\1\s\Xamarin.Forms.Platform.Android\Renderers\ListViewAdapter.cs:413
at Android.Widget.BaseAdapter.n_IsEnabled_I (System.IntPtr jnienv, System.IntPtr native__this, System.Int32 position) [0x00008] in <263adecfa58f4c449f1ff56156d886fd>:0
at (wrapper dynamic-method) System.Object.389216aa-a260-49e0-aaaa-e4e2031ad22f(intptr,intptr,int)"
这是我的配置:
Mono 8.1
Xamarin.Forms 3.3.0.893527-pre3
Xamarin.Android.Support.Design 27.0.2.1
Xamarin.Android.Support.v7.AppCompat 27.0.2.1
Xamarin.Android.Support.v4 27.0.2.1
Xamarin.Android.Support.v7.CardView 27.0.2.1
Xamarin.Android.Support.v7.MediaRouter 27.0.2.1
Xamarin.GooglePlayServices.Location 60.1142.1
Xamarin.GooglePlayServices.Maps 60.1142.1
Xamarin.Essentials 0.10.0-preview
你知道怎么解决这个问题吗?
问候
发布于 2019-04-20 02:39:16
你现在可能已经解决了你的问题,但是把这个留给遇到这个问题的其他人吧。
感谢Jason的问题,它引导我清理了对列表视图逻辑的可绑定项源代码的操作。我做了很多.Clear(),并补充说我不需要这样做。我减少了这些的数量,它为我解决了这个问题。所以我将看看您是如何处理列表视图的ItemSource的。
https://stackoverflow.com/questions/52783736
复制相似问题