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

Unhandled index out of range expection when setting datasource

Dear support,


I updated the SfComboBox nuget package to the latest version, version 20.3.0.47. I am using Xamarin forms version 5.0.0.2012. When I add items to the ObservableCollection which I binded to the DataSource property of the SfComboBox, there is an unhandled exception and the app crashes. The error details are:


System.ArgumentOutOfRangeException

  Message=Index was out of range. Must be non-negative and less than the size of the collection.

Parameter name: index


I get the error when I do the following:

Class:

public class Test

{

    public int ID { get; set; }

    public string Description { get; set; }

}

In ViewModel:

private ObservableCollection<Test> list;

public ObservableCollection<Test> List

{

    get { return list; }

    set

    {

        list = value;

        OnProperyChanged();

    }

}


public ViewModel()

{

    List = new ObservableCollection<Test>();

    list.Add(new Test { ID = 1, Description = "Test" });

}


In XAML:

<inputLayout:SfTextInputLayout ContainerBackgroundColor="Transparent"

                                                               Hint="Test">

                                    <combobox:SfComboBox ShowSuggestionsOnFocus="True"

                                                         HeightRequest="65"

                                                         BorderColor="Red"

                                                         DisplayMemberPath="Description"

                                                         SelectedValuePath="ID"

                                                         DataSource="{Binding List}"/>

                                </inputLayout:SfTextInputLayout>


3 Replies

RS Ruba Shanmugam Syncfusion Team October 6, 2022 12:58 PM UTC

Hi Jano,


Query: Unhandled index out of range expection when setting datasource


We have checked the reported query and we have already fixed the issue in our latest version. Could you please check your application with the latest version of SfComboBox 20.3.0.48 and let us share the details if you still facing the same problem?


Regards,

Ruba Shanmugam



DE Denis April 20, 2023 02:45 PM UTC

Hi,

the error is repeated in 21.1.41 if the property IsEditableMode is set True - and only on Android.

Help this?


Tnx!



EA EwaldJebaraj Anandaraj Syncfusion Team April 21, 2023 01:01 PM UTC

Hi Jano,

We were unable to reproduce the reported scenario on our end. To better understand the root cause and assist with resolving the issue, it would be helpful if you could provide more detailed information about the scenario in which our control was used, including a sample demonstrating the issue with replication steps. Please let us know if you have any other queries.

Kindly review the attached example and apply any required modifications to reproduce the problem. Afterward, kindly forward the sample to us, as it would enable us to conduct a more thorough investigation of the issue



Attachment: ComboBox_177985_fe40b4b9.zip

Loader.
Live Chat Icon For mobile
Up arrow icon