Drag RadTileViewItem outside window

5 posts, 1 answers
  1. Kevin
    Kevin avatar
    3 posts
    Member since:
    Dec 2012

    Posted 27 Dec 2012 Link to this post

    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..
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 01 Jan 2013 Link to this post

    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.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Kevin
    Kevin avatar
    3 posts
    Member since:
    Dec 2012

    Posted 02 Jan 2013 Link to this post

    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)
        {

        }
      }
  5. Answer
    Nick
    Admin
    Nick avatar
    593 posts

    Posted 03 Jan 2013 Link to this post

    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.

  6. Kevin
    Kevin avatar
    3 posts
    Member since:
    Dec 2012

    Posted 04 Jan 2013 Link to this post

    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!
Back to Top
UI for WPF is Visual Studio 2017 Ready