Hi Rosy,
The issue seems to be caused by a customrenderer in Android.
If you are using the renderer below the calling Collection.Clear() will throw an exception.
public
class
CustomRadListRenderer : ListViewRenderer
{
protected
override
SwipeExecuteBehavior CreateSwipeExecuteBehavior(ListViewDataSourceAdapter adapter)
{
var behavior =
base
.CreateSwipeExecuteBehavior(adapter);
behavior.AutoDissolve =
false
;
behavior.SwipeLimitStart = 0;
return
behavior;
}
}
The code is to stop the user swiping and revealing from the right. If I stop using the CustomRenderer then clear/add etc work as expected.
I'm guessing this approach has been deprecated for an newer approach but I'm not sure. Also could you advice how to stop this behavior in iOS?
The error is shown below:
System.Collections.Generic.KeyNotFoundExceptionThe given key was not present
in
the dictionary.
Raw
System.ThrowHelper.ThrowKeyNotFoundException()
System.Collections.Generic.Dictionary<TKey, TValue>.get_Item(TKey key)
at Telerik.XamarinForms.Common.XamarinToNativeControlExtensions.UpdateCollection[T,K] (Telerik.XamarinForms.Common.T nativeElement, Telerik.XamarinForms.Common.K xfЕlement, System.String propertyName, System.Collections.Specialized.NotifyCollectionChangedEventArgs args) <0x897cd380 + 0x0005b>
in
<filename unknown>:0
Telerik.XamarinForms.DataControlsRenderer.Android.ListViewRenderer.ItemsSource_CollectionChanged(
object
sender, NotifyCollectionChangedEventArgs e)
Telerik.XamarinForms.DataControls.RadListView.RaiseItemsSourceCollectionChanged(
object
sender, NotifyCollectionChangedEventArgs e)
System.Collections.ObjectModel.ObservableCollection<T>.OnCollectionChanged(NotifyCollectionChangedEventArgs e)
System.Collections.ObjectModel.ObservableCollection<T>.OnCollectionReset()
System.Collections.ObjectModel.ObservableCollection<T>.ClearItems()
System.Collections.ObjectModel.Collection<T>.Clear()
I'd rather ensure the Listview's as expected rather than coding in workarounds for data binding so it would be good if I could get a solution, essentially I only want the user to swipe right on a listitem and not allow swipe left.
Thanks again.,
Norman.