This is a migrated thread and some comments may be shown as answers.

Prevent RadListBox from selecting item when drag drop an item out

3 Answers 200 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Etienne
Top achievements
Rank 1
Etienne asked on 17 Apr 2015, 06:36 PM

Hi,

I have RadListBoxes that represents categories. Each of these RadListBox contains items that can be dragged to another category. Only one item can be selected across all the RadListBox. When I drag an item from a category to an other, the category from where I drag set selected to an item that it contains. Is there a way to prevent that behavior because I would like that the dragged item stays selected.

I attached a sample solution that represent the situation : drag an item from category A to another category and the selected item should be the dragged item in the drop category.

Thank you,

Etienne

3 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 22 Apr 2015, 02:43 PM
Hello Etienne,

The observed by you appearance of RadListBox is caused by the CollectionViewSource to which the ItemsSource is bound to. The collection does not Refresh when it Source changes - thus the selection is preserved. We recommend you to use collections like ObservableCollection that updates the UI automatically once a change of its source is made. We have modified your sample project with the described above approach and you could check it how it works when ObservableCollection is used.

Hopes this helps.

Regards,
Nasko
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
0
Etienne
Top achievements
Rank 1
answered on 01 Feb 2016, 04:36 PM

Hi Nasko,

Thanks for your answer and sorry for my very very very late reply. I tried your solution and it does fix the selection problem but without the CollectionViewSource (and live filtering), when the category of an item is changed by another method than drag and drop it's not updated in the view. I updated the sample project with the described problem. You just have to drag an item to another category and press the "A" button, you'll see that the item is not moved to category A.

Thank you,

 Etienne

0
Nasko
Telerik team
answered on 03 Feb 2016, 09:40 AM
Hello Etienne,

Unfortunately, currently we do not have such an example that demonstrates how to achieve the desired by you exact behavior with ObservableCollection. As you have already noticed in order to perform the desired filtering the CollectionViewSource needs to be used, but that will cause the initial observed selection issue. The only approach that we could think of in order to continue using the ObservableCollection and achieve the desired behavior is to remove the item from collection when the button gets pressed and add it to the collection that corresponds to the changed category.

I hope this will help you.

Regards,
Nasko
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Tags
ListBox
Asked by
Etienne
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Etienne
Top achievements
Rank 1
Share this question
or