Declined
Last Updated: 28 Mar 2018 11:57 by ADMIN
ADMIN
Stefan
Created on: 16 Feb 2017 13:12
Category: ListBox
Type: Bug Report
0
ListBox: When the SelectedItem is set to be an object that is not present in the source collection, the selection is not cleared
The issue can be reproduced in a scenario in which there are a RadListBox and a RadGridView defined and their SelectedItem properties are bound to the same property in the view model. The source collection of RadListBox contains some objects present in the one bound to RadGridView's ItemsSource. If the user selects an item in RadGridView that is also present in the items of RadListBox, the selection is performed in both controls as expected. However, when already having a selected item in both controls, if the user selects an item in RadGridView that is not present in the items of RadListBox, the selection in RadListBox is not cleared. Thus, in order to selected the previously selected item, it needs to be deselected and selected again.

UPDATE:
After the researching the issue, it seems that the logic for handling the case when a SelectedItem that is not present in the source collection is being set is slightly different for Silverlight and WPF. For the WPF version of the control a DependencyProperty.UnsetValue is used, whereas a null value is set for the Silverlight RadListBox. Thus, in Silverlight the selection is cleared and in WPF it is not. I am afraid, that we cannot commit ourselves to modifying this by-design implementation, as this will result in a braking change. With this in mind, I will update the status of the logged bug to Declined.

What we can suggest as a workaround, would be to define a second calculated property in the view model and bind the SelectedItem of RadListBox to it. The logic in the property setter would be to set a null value if the SelectedItem is not present in the source collection of RadListBox.
0 comments