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

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

5 Answers 46 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 27 Jul 2013, 05:04 PM
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

5 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 31 Jul 2013, 07:08 AM
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 >>
0
Ben
Top achievements
Rank 1
answered on 06 Dec 2013, 05:39 AM
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
0
Nick
Telerik team
answered on 06 Dec 2013, 12:04 PM
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 >>
0
Ben
Top achievements
Rank 1
answered on 06 Dec 2013, 07:44 PM
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

0
Nick
Telerik team
answered on 09 Dec 2013, 09:23 AM
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 >>
Tags
DragAndDrop
Asked by
Mark
Top achievements
Rank 1
Answers by
Nick
Telerik team
Ben
Top achievements
Rank 1
Share this question
or