We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Setting itemsource dinamically throws argumentOutOfRangeException

Thread ID:

Created:

Updated:

Platform:

Replies:

143275 Mar 12,2019 04:38 PM UTC Mar 14,2019 03:55 AM UTC Xamarin.Forms 2
loading
Tags: SfPicker
Tamas Cons
Asked On March 12, 2019 04:38 PM UTC

Hello.We built a temperaturePicker starting from SfPicker where bind the ItemsSource property of the picker to an ObservableCollection<object> that has other three ObservableCollection<object> elements that represents the three colums that the picker has.First one of those represents the whole part of the temperature(23,24,25 etc), the second one is just a point represented by a string basically,the third one is the decimal part of the temperature(0,1,2,3,4 ,5,6,7,8,9). The first and third part changes dinamically,and when we assign a new ObservableCollection<object> to one of these columns it can crash with an ArgumentOutOfRangeException.This issue is a blocker to us.
Please see the attached screenshot and the code below(this code is the one that handles the replacing of the decimal collection and is called from the OnSelectionChanged method.
Part of the code:

private void ReplaceDecimalValues(ObservableCollection<object> newDecimalCollection, object initialDecimal = null)
{
var collection = ItemsSource as ObservableCollection<object>;
if (collection?.Count > 2 && IsOpen)
{
                              //The crash is on the below line.If we use collection.RemoveAt(2) and then collection.Add,it does not work,as the third column,that was removed,is not visible/present anymore
collection[2] = new ObservableCollection<object>(newDecimalCollection);
if (Device.RuntimePlatform == Device.Android)
{
var selectedItems = SelectedItem as ObservableCollection<object>;
if (selectedItems?.Count > 2)
{
selectedItems[2] = (newDecimalCollection.Contains(initialDecimal)) ? initialDecimal : newDecimalCollection.First();
}

if (_isFirstDecimalInitialization && selectedItems != null)
{
SelectedItem = new ObservableCollection<object>(selectedItems);
_isFirstDecimalInitialization = false;
}
}
else
{
var selectedItems = SelectedItem as ObservableCollection<string>;
if (selectedItems?.Count > 2)
{
selectedItems[2] = (newDecimalCollection.Contains(initialDecimal))? initialDecimal?.ToString():newDecimalCollection.First().ToString();
}
}
}
}

Please let us know how we can fix this issue,Regards,Norbert

Attachment: crash_86a960aa.rar

Tamas Cons
Replied On March 13, 2019 07:52 AM UTC

SfPicker nuget package version 16.2.0.50

Eswaran Thirugnanasambandam [Syncfusion]
Replied On March 14, 2019 03:55 AM UTC

Hi Tamas,

Greetings from Syncfusion.

We have checked with your reported issue and this has been fixed in our latest version (16.4.0.54). So please update your nuGet version to latest and check whether issue has been resolved in your side.

Regards,
Eswaran T

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon