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. Image for the cookie policy date
close icon

Setting itemsource dinamically throws argumentOutOfRangeException

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

2 Replies

TC Tamas Cons March 13, 2019 07:52 AM UTC

SfPicker nuget package version 16.2.0.50


ET Eswaran Thirugnanasambandam Syncfusion Team 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

Loader.
Live Chat Icon For mobile
Up arrow icon