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