ItemsSource not refreshing

I've an sfComboBox where the ItemsSource is bound to an ObservableCollection, but when I update values in the observable collection, the ComboBox doesn't update.

I've also tried adding and removing an object to the end of the collection to force a collection changed event, but the combobox still reflects the original list?

 


4 Replies

JT John Taylor September 4, 2023 05:01 PM UTC

In the end I created a List<t> to use as the ItemsSource and just recreated it from the collection whenever an object was popped or pushed (seems mad though)



AJ AhamedAliNishad JahirHussain Syncfusion Team September 5, 2023 12:32 PM UTC

Hi John,

 

We have reviewed your query and we have created a sample based on the provided information. In the sample, we have a SfComboBox loaded with data using the ItemSource bound to the Observablecollection Type property. Additionally, we have two buttons, "Add item" and "Remove item," to modify the collection. However, we were not able to reproduce the reported issue. We have attached the tested sample for your reference.

 

Please review the attached example and make any necessary modifications to reproduce the problem. Afterwards, kindly forward the sample to us so that we can conduct a more thorough investigation of the issue.

 

Regards,

Ahamed Ali Nishad.


Attachment: SfComboItemSource_9b8d3099.zip


JT John Taylor September 5, 2023 03:34 PM UTC

The issue I have is when I change one of the items... so if I have an ObservableCollection<animal> populated with Cat, Dog, Elephant, and set that as ItemsSource... If I then swap the Dog out for a Mouse, the comboBox still reads Cat, Dog, Elephant.

I was looking for the ComboBox to detect a changed item in the collection.


Thanks

John 



AJ AhamedAliNishad JahirHussain Syncfusion Team September 6, 2023 11:17 AM UTC

Hi John,

 

We have reviewed your query and, based on the latest provided information, we have modified the sample. In the sample, we have a SfComboBox populated with data such as Cat, Dog, and Elephant, and we have added one button labeled "Replace Item". In the Button Click event method, we have changed the second item to Mouse from Dog. The changed collection is reflected in the UI only if we include the INotifyPropertyChanged interface to the Model class in order to notify the UI that the property has changed. Now the changed item is reflected correctly. Please review the attached sample and let us know the details.

 

If you are still facing the issue, please share the sample that replicates the issue. This will help us investigate better and provide you with a prompt solution as soon as possible.

 

Regards,

Ahamed Ali Nishad.


Attachment: SfComboItemSwap_5f1312a2.zip

Loader.
Up arrow icon