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

Complete Drop on Mouse button up?

5 Answers 74 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Jeremy
Top achievements
Rank 1
Jeremy asked on 28 Feb 2012, 03:50 AM
I am currently using the RadDragAndDropManager for the first time and dragging from a RadTreeView to a RadPaneGroup.
Seems to do most of what I need; I'm currently doing all the work on the DropInfoHandler.

The problem I have, is that the "DropInfo" event fires IMMEDIATELY when I drag the RadTreeViewItem over the pane, rather than when I let go of the left mouse button. This is an issue because I have multiple grids, and the user will want to drag over the top of some grids to get to other grids.

Is this functionality by design, or have I done something wrong?


XAML:
<telerik:RadDocking x:Name="Docking" Close="Docking_Close">
 
   <telerik:RadSplitContainer InitialPosition="DockedLeft" Width="240" >
      <telerik:RadPaneGroup>
         <telerik:RadPane x:Name="rpDatabaseBrowser" Header="Database Browser">
            <Grid>
               <telerik:RadTreeView Name="RadTreeView1" ImagesBaseDir="/Images/" LoadOnDemand="RadTreeView1_LoadOnDemand" IsDragDropEnabled="True" telerik:RadDragAndDropManager.AllowDrop="False">
               </telerik:RadTreeView>
            </Grid>
         </telerik:RadPane>
      </telerik:RadPaneGroup>
   </telerik:RadSplitContainer>
 
   <telerik:RadDocking.DocumentHost>
      <telerik:RadSplitContainer>
                     
         <telerik:RadPaneGroup x:Name="rpg1" telerik:RadDragAndDropManager.AllowDrop="True">
            <telerik:RadPane x:Name="rp1" Title="Pane 1">
               <Grid>
                  <telerik:RadGridView x:Name="GridView1" Visibility="Hidden" DataLoadMode="Asynchronous">
                  </telerik:RadGridView>
               </Grid>
            </telerik:RadPane>
         </telerik:RadPaneGroup>
 
         <telerik:RadPaneGroup x:Name="rpg2" telerik:RadDragAndDropManager.AllowDrop="True">
            <telerik:RadPane x:Name="rp2" Title="Pane 2">
               <Grid>
                  <telerik:RadGridView x:Name="GridView2" Visibility="Hidden" DataLoadMode="Asynchronous">
                  </telerik:RadGridView>
               </Grid>
            </telerik:RadPane>
         </telerik:RadPaneGroup>
 
      </telerik:RadSplitContainer>
   </telerik:RadDocking.DocumentHost>
 
</telerik:RadDocking>



Code behind
public MainWindow()
{
   InitializeComponent();
   RadDragAndDropManager.AddDropInfoHandler(rpg1, OnDatabaseBrowserDropInfo);
   RadDragAndDropManager.AddDropInfoHandler(rpg2, OnDatabaseBrowserDropInfo);
}
 
private void OnDatabaseBrowserDropInfo(object sender, DragDropEventArgs e)
{
   //work out which RadTreeViewItem is dragged from
   //work out which RadPaneGroup is dropped on
   //populate Grid on RadPane
}

5 Answers, 1 is accepted

Sort by
0
Nick
Telerik team
answered on 28 Feb 2012, 05:50 PM
Hi Jeremy,

By design this is the expected behavior. If you want to execute some kind of custom drop logic, you should do it only if the EventArgs.State is DropCompleted. 
You can see a sample implementation of it in our documentation here.

Hope this helps!

Regards,
Nik
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Jeremy
Top achievements
Rank 1
answered on 29 Feb 2012, 06:48 AM
hmmm kinda - how do I hook up the mouse-up event to it?
Also is that link supposed to be pointing to the Silverlight documentation?
0
Nick
Telerik team
answered on 01 Mar 2012, 04:25 PM
Hello Jeremy,


Sorry about the wrong link. Here is the proper one. 
Could you clarify what exactly do you mean "to hook up the mouse-up event to it" ? What exactly are you trying to achieve? 


All the best,
Nik
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Jeremy
Top achievements
Rank 1
answered on 07 Mar 2012, 02:37 AM
Hi Nik

I am wanting to only allow the drop operation when the user releases the left mouse button.

Kind Regards,
Jeremy
0
Nick
Telerik team
answered on 09 Mar 2012, 12:30 PM
Hello Jeremy,

The RadDragAndDropManager is based on events that rely to a certain Drag/Drop status. What you are looking for is the Drop/Drag info events, with statuses DragCompleted/DropCompleted. You have to execute the custom Drop logic in the handlers for those two events. I.e. if you want to add the new items to the destination, it would look something like this:

private void OnDropInfo( object sender, DragDropEventArgs e )
{
    ItemsControl box = e.Options.Destination as ItemsControl;
    IList<ApplicationInfo> itemsSource = box.ItemsSource as IList<ApplicationInfo>;
    ApplicationInfo payload = e.Options.Payload as ApplicationInfo;
    if ( e.Options.Status == DragStatus.DropComplete )
    {
        if ( !itemsSource.Contains( payload ) )
        {
            itemsSource.Add( payload );
        }
    }
}
You can read more about the Drag and Drop mechanism here. And see the exact events occurring order here.

Hope this helps! 

Kind regards,
Nik
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Tags
DragAndDrop
Asked by
Jeremy
Top achievements
Rank 1
Answers by
Nick
Telerik team
Jeremy
Top achievements
Rank 1
Share this question
or