Listbox DragDrop inside TileView

2 posts, 1 answers
  1. Wenrong
    Wenrong avatar
    36 posts
    Member since:
    May 2012

    Posted 25 Oct 2012 Link to this post

    Please find the sample project here

    The sample application is divided into two parts:

    The bottom part is similar to the RadListBox drag-n-drop demo with 4 elements:
    1. RadListBox bound to ObservableCollection<Country> CountryList
    2. RadListBox bound to ObservableCollection<Country> GroupA
    3. RadListBox bound to ObservableCollection<City> GroupD
    4. WPF ListBox bound to ObservableCollection<Country> GroupA, AllowDrop unset

    The Drag-n-Drop behaviour is as expected, I can drag n drop between 1&2, but not to 3 or 4, it worked very well.

    The top part is the identical setup, except it is contained within a RadTileView, and there are a few unexpected behaviours:

    1. Cursor no longer change to Cursors.No when drag over list 3 & 4
    2. When dropped on list 3, nothing happens, this is good. But when dropped on list 4 or anywhere on the tileview that's not a RadListBox, the item is removed from the drag source, and not added to anywhere.

    So how do I fix these two issues?
  2. Answer
    Zarko
    Admin
    Zarko avatar
    755 posts

    Posted 26 Oct 2012 Link to this post

    Hello Wenrong,
    Thank you for the feedback and I'll try to answer your questions:
    - this is an issue in the RadTileView and it will be fixed in some of our next releases
    - the problem is that the RadTileView is also listening for Drop events and that's why you items disappear.
    You can workaround both of your problems with this code:
    private bool isTileViewDrag = false;
     
    public MainWindow()
    {
        InitializeComponent();
     
        DragDropManager.AddDragInitializeHandler(this.tileView, OnDragInit);
        DragDropManager.AddGiveFeedbackHandler(this.tileView, OnGiveFeedback);
    }
     
    private void OnGiveFeedback(object sender, Telerik.Windows.DragDrop.GiveFeedbackEventArgs e)
    {
        if (!this.isTileViewDrag)
        {
            e.Handled = true;
            e.UseDefaultCursors = true;
        }
    }
     
    private void OnDragInit(object sender, DragInitializeEventArgs e)
    {
        var container = e.OriginalSource as RadTileViewItem;
        if (container != null)
        {
            this.isTileViewDrag = true;
            this.tileView.AllowDrop = true;
        }
        else
        {
            this.isTileViewDrag = false;
            this.tileView.AllowDrop = false;
        }
    }
    If you have further questions please feel free to ask.

    All the best,
    Zarko
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top