This issue that is occurring is that whenever the RadComboBox’s ItemsSource property is changed the SelectedItem property is being set to null.
Requirements to recreate issue:
- Original ItemsSource is a collection of objects that ARE NOT value types
- SelectedValue is bound to some property
- SelectedValuePath is set
- SelectedItem is some item in the original ItemsSource
- New ItemsSource is a collection of objects of the same type as the original ItemsSource that does not contain a reference to the same object in memory as the current SelectedItem
What is happening is that when the new ItemsSource is set the RadComboBox is finding that none of the new items reference the same object in memory as the current SelectedItem and so setting the SelectedItem to null.
However, I have defined the SelectedValuePath so I clearly want the RadComboBox’s selection mechanism to be driven by the SelectedValue and not the SelectedItem. What I feel should be happening is that when the ItemsSource changes and the SelectedValuePath is not null the RadComboBox would then compare the value of the property at the SelectedValuePath of the SelectedItem to the value of the property at the SelectedValuePath for each item in the new ItemsSource. And only then, if it cannot find a match set the SelectedItem to null.
This issue was difficult to track down and has been particularly vexing for us because we are using the Csla framework in our project. When using this framework, whenever we perform an operation on a business object we are returned a COPY of that object not the original object. If that object happens to be a collection that a RadComboBox’s ItemsSource is bound to then the SelectedItem is getting wiped out.
9 Answers, 1 is accepted

We have exactly the same problem as you describe below.
After several trial and errors, we found that the underlying Type of your SelectedValue property has to be the same type (or equivalent Nullable<T> type also seems to work) as the value property of the SelectedItem in the ItemsSource.
Give it a try.
Stefan Buys

The SelectedValue types in the new collection are of the same type as the old collection. In fact I can replace the original ItemsSource with a clone of the original ItemsSource where everything is exactly the same except that the objects reside at a different location in memory and the SelectedItem gets wiped out. I would also point out the the objects at SelectedValuePath ARE value types so they are not being compared by reference.
I have mocked up a sample project demonstrating this but I don't see any way to attach it. I only have the option to attach images.

Take the below simplified example:
<
telerik:RadComboBox
x:Name
=
"SearchTypes"
ItemsSource
=
"{Binding Path=SearchTypes}"
DisplayMemberPath
=
"Description"
SelectedValuePath
=
"Id"
SelectedValue
=
"{Binding Path=QueryCriteria.SearchTypeId, Mode=TwoWay"
SelectedItem
=
"{Binding Path=SelectedSearchType, Mode=TwoWay"
>
</
telerik:RadComboBox
>
In our case, the "SelectedSearchType.Id" and "QueryCritiera.SearchTypeId" types must be the same to avoid setting the SelectedSearchType property to null as you've described. If its the same already, you have a different problem indeed!
NOTE: In terms of changing the ItemsSource, I haven't seen any difference in behaviour between assigning a different object reference collection or a copied collection.
Stefan


No mention of when this will be fixed or if they even believe this a bug that needs fixing.

Has above issue been fixed in silverlight RadCombobox.
We are using virtualized Radcombobox in our project. since virtualization does not support filtering so we have created custom filtering mechenism by extending RadCombobox and defined new VirtuzalisedRadCombobox.
We placed this VirtuzalisedRadCombobox in CellEditTemplate. But when we select new value from drop down, then selected value gets null and also itemsource gets null.
Can anybody please let me know whats the reason of the issue.
We are not sure what the issue exactly is. The previously discussed issues is related to when the ItemsSource of the control is changed which causes the SelectedItem to be reset. That issue is resolved by overriding the Equals of the bound objects to the RadComboBox control.
I created and attached a sample project for you that shows the mentioned approach. In the project if you click the change button the SelectedItem (Item 1) will not be reset. If this is not the case could you open a support ticket and send us a sample project that recreated the issue so that we can observe it on our side and see what could be the cause of it?
Regards,
Vladi
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>

As we see you have posted a support thread about the same issue could we continue the decision there.
I will post our response from that other thread in order for it to be available for the community:
We are not aware of any issues related to the "Clear Selection" button that could cause the selection to be cleared without the button being clicked.
Regards,
Vladi
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>