Prevent RadListBox from selecting item when drag drop an item out

4 posts, 0 answers
  1. Etienne
    Etienne avatar
    47 posts
    Member since:
    Sep 2014

    Posted 17 Apr 2015 Link to this post

    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

  2. Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 22 Apr 2015 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Etienne
    Etienne avatar
    47 posts
    Member since:
    Sep 2014

    Posted 01 Feb in reply to Nasko Link to this post

    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

  5. Nasko
    Admin
    Nasko avatar
    585 posts

    Posted 03 Feb Link to this post

    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
Back to Top