Complete Drop on Mouse button up?

6 posts, 0 answers
  1. Jeremy
    Jeremy avatar
    96 posts
    Member since:
    Mar 2010

    Posted 27 Feb 2012 Link to this post

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

    Posted 28 Feb 2012 Link to this post

    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 >>
  3. UI for WPF is Visual Studio 2017 Ready
  4. Jeremy
    Jeremy avatar
    96 posts
    Member since:
    Mar 2010

    Posted 29 Feb 2012 Link to this post

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

    Posted 01 Mar 2012 Link to this post

    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 >>
  6. Jeremy
    Jeremy avatar
    96 posts
    Member since:
    Mar 2010

    Posted 06 Mar 2012 Link to this post

    Hi Nik

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

    Kind Regards,
    Jeremy
  7. Nick
    Admin
    Nick avatar
    593 posts

    Posted 09 Mar 2012 Link to this post

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