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

Drag RadTileViewItem outside window

4 Answers 148 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Kevin
Top achievements
Rank 1
Kevin asked on 27 Dec 2012, 07:32 PM
Can someone post an example of how to detect that a radtileviewitem has been dragged outside of window it is contained in? 

I'm using the new DragDropManager and have already attached the events to the tileviewitem (draginitialize, dragleave, dragcompleted, etc.) but can't seem to figure out how to tell if the item is outside it's parent window from the args in the DragDropCompletedEventArgs eventargs. Dragleave seems to fire if the item has left the tileview container. I want to capture this if it has left it's parent window.

Many thanks..

4 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 01 Jan 2013, 01:32 PM
Hello Kevin,

You can subscribe to the DragLeave event for the window, which should fire when something is dragged out of it.

Let me know if this works for you! 

All the best,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kevin
Top achievements
Rank 1
answered on 02 Jan 2013, 03:49 PM
I tried that. Perhaps I am missing something fundamentally basic here.. Forgive me but here is an example completely stripped of viewmodel, all code embedded in the window and code behind - and still resulting in the same behavior.

The Window has the draginit and leave handlers attached to it (the red area).
The Tileview has dragging enabled on the items (the green area)

The OnDragLeave event fires when the tile is dragged outside the green area, my expectation here is that it would fire when dragging it outside the red area.

Thanks,
Kevin

<Window x:Name="MyWindow"
        Background="Red"
        x:Class="TestDrag.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:Controls="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation" Title="MainWindow">
    <Grid>
      <StackPanel Height="200">
        <Controls:RadTileView Background="Green" 
                              IsItemDraggingEnabled="True"
                              AllowDrop="True">
          <Controls:RadTileViewItem Width="200">
            Test
          </Controls:RadTileViewItem>
        </Controls:RadTileView>
      </StackPanel>
  </Grid>
</Window>

 public partial class MainWindow : Window
  {
    public MainWindow()
    {
      InitializeComponent();
      DragDropManager.AddDragInitializeHandler(MyWindow, OnDrag);
      DragDropManager.AddDragLeaveHandler(MyWindow, OnDragLeave);
    }

    private void OnDrag(object sender, DragInitializeEventArgs e)
    {
      e.AllowedEffects = DragDropEffects.All;
    }

    private void OnDragLeave(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
    {

    }
  }
0
Accepted
Nick
Telerik team
answered on 03 Jan 2013, 12:54 PM
Hello Kevin,

The problem is that you have to set AllowDrop to true on the Window in order torecieve drag drop events for it. 
Note that by doing so, the Window will recieve any unhandled drag drop events for its children. Meaning that it will recieve the TileView's DragLeave event if it isn't handled explicitly.

Hope this helps! 

Greetings,
Nik
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Kevin
Top achievements
Rank 1
answered on 04 Jan 2013, 04:05 PM
Works well. It's too bad i have to now add an "IgnoreDrag" behavior to the child that basically does nothing on the DragLeave event to get it to work, but it does the trick. Makes sense.. Many thanks!
Tags
DragAndDrop
Asked by
Kevin
Top achievements
Rank 1
Answers by
Nick
Telerik team
Kevin
Top achievements
Rank 1
Share this question
or