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

Listbox DragDrop inside TileView

1 Answer 56 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Wenrong
Top achievements
Rank 1
Wenrong asked on 26 Oct 2012, 01:24 AM
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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Zarko
Telerik team
answered on 26 Oct 2012, 04:01 PM
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.

Tags
DragAndDrop
Asked by
Wenrong
Top achievements
Rank 1
Answers by
Zarko
Telerik team
Share this question
or