Migrate RadD&D -> DragDropManager - no allow.drop?

6 posts, 0 answers
  1. Mark
    Mark avatar
    155 posts
    Member since:
    Oct 2010

    Posted 27 Jul 2013 Link to this post

    Hi and thanks for reading.

    I'm looking to confirm there is no property (by design) to prevent an allow drop state as existed in RadDragAndDrop?

    This was really a great feature that allowed preventing accidental drops through less code.
    I understand we can code the logic on each drop target, but a simple Boolean was really great.

    Thanks,
    Mark
  2. Nick
    Admin
    Nick avatar
    593 posts

    Posted 31 Jul 2013 Link to this post

    Hello Mark,

    The DragDropManager uses Microsofts default AllowDrop property to process the Drop requests. 

    Hope this helps! 

    Regards,
    Nik
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. DevCraft banner
  4. Ben
    Ben avatar
    9 posts
    Member since:
    Aug 2012

    Posted 05 Dec 2013 Link to this post

    Hi Nik,

    Related to the topic of this post, I had to change this snippet of code after upgrading from Telerik 2011.Q1 to Telerik 2013.Q1 :-

          /// <summary>
          /// Initializes the drag and drop of the associate object.
          /// </summary>
          protected virtual void Initialize()
          {
             this.AssociatedObject.RowLoaded += this.AssociatedObject_RowLoaded;
             this.AssociatedObject.SetValue(RadDragAndDropManager.AllowDropProperty, true); // <---- Need to update this line to use DragDropManager
             this.SubscribeToDragDropEvents();
          }

    How should I change the highlighted line above since the AllowDropProperty does not exist in the newer DragDropManager?

    Regards,
    Ben
  5. Nick
    Admin
    Nick avatar
    593 posts

    Posted 06 Dec 2013 Link to this post

    Hi Ben,

    You need to set the AllowDropProperty of the associated object. 
    this.AssociatedObject.AllowDrop = true;


    Hope this helps! 

    Regards,
    Nik
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  6. Ben
    Ben avatar
    9 posts
    Member since:
    Aug 2012

    Posted 06 Dec 2013 Link to this post

    Hi Nik,

    That was quick! Thanks for that.
    There is another place which needs changing which I am not sure about :-

    How would I convert the following snippets of code from RadDragAndDropManager to DragDropManager?
    ...
             RadDragAndDropManager.RemoveDropQueryHandler(row, this.OnGridViewRowDropQuery);
             RadDragAndDropManager.AddDropQueryHandler(row, this.OnGridViewRowDropQuery);
    ...

          /// <summary>
          /// Handles the DropQuery Event of GridViewRow.
          /// </summary>
          /// <param name="sender">The sender object.</param>
          /// <param name="e">The instance of the <see cref="DragDropQueryEventArgs"/> class.</param>
          private void OnGridViewRowDropQuery(object sender, DragDropQueryEventArgs e)
          {
             if (!(e.Options.Source is GridViewRow))
             {
                return;
             }

             GridViewRow row = sender as GridViewRow;

             if (row != null)
             {
                if (e.Options.Status == DragStatus.DropDestinationQuery)
                {
                   this.currentDropItem = row.Item;
                   this.currentDropPosition = this.GetDropPositionFromPoint(e.Options.CurrentDragPoint, row);

                   e.QueryResult = true;
                   e.Handled = true;
                }
             }
          }


    I tried changing to the following:

             DragDropManager.RemoveDropHandler(row, this.OnGridViewRowDropQuery);
             DragDropManager.AddDropHandler(row, this.OnGridViewRowDropQuery);
    ...

          /// <summary>
          /// Handles the DropQuery Event of GridViewRow.
          /// </summary>
          /// <param name="sender">The sender object.</param>
          /// <param name="e">The instance of the <see cref="Telerik.Windows.DragDrop.DragEventArgs"/> class.</param>
          private void OnGridViewRowDropQuery(object sender, Telerik.Windows.DragDrop.DragEventArgs e)
          {
             if (!(e.Options.Source is GridViewRow))
             {
                return;
             }

             GridViewRow row = sender as GridViewRow;

             if (row != null)
             {
                if (e.Options.Status == DragStatus.DropDestinationQuery)
                {
                   this.currentDropItem = row.Item;
                   this.currentDropPosition = this.GetDropPositionFromPoint(e.Options.CurrentDragPoint, row);

                   e.QueryResult = true;
                   e.Handled = true;
                }
             }
          }


    But the compiler does not recognize the e.Options and e.QueryResult properties any longer. It would be great if you could help point out what needs to be done to make the migration from RadDragandDropManager to DragDropManager complete. Once you point me in the right direction, I shall apply the same changes to the remaining code and their respective event handlers:-
             RadDragAndDropManager.AddDropInfoHandler(this.AssociatedObject, this.OnDropInfo);
             RadDragAndDropManager.AddDragQueryHandler(this.AssociatedObject, this.OnDragQuery);
             RadDragAndDropManager.AddDragInfoHandler(this.AssociatedObject, this.OnDragInfo);

    Regards,
    Ben

  7. Nick
    Admin
    Nick avatar
    593 posts

    Posted 09 Dec 2013 Link to this post

    Hi Ben,

    The new DragEventArgs do not contain property "Options". You can work with the OriginalSource property in order to find the Source of the DragOperation instead.

    You can see this article which can assist you greatly in your efforts on Migrating.
    Here are some Drag and Drop examples you can use as a reference:
    http://demos.telerik.com/silverlight/#GridView/RowReorder
    http://demos.telerik.com/silverlight/#DragAndDrop/TreeToGrid
    http://demos.telerik.com/silverlight/#TreeListView/TreeListViewDragAndDrop


    Hope this helps! 


    Regards,
    Nik
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top
DevCraft banner