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

Drag & Drop works except inside a Popup

11 Answers 216 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
Pinho
Top achievements
Rank 1
Pinho asked on 01 Jun 2009, 03:07 PM
Hi all,

 I'm building a search box and the user can define advanced filters by clicking on one button. The allowed filters are shown inside a tree (teleriks) and can be dragged to a table (RadGridView). To make a new filter, the user just as to drag the filter name inside the tree into the filter table.

 This is working fine, until now. To avoid changing the layout everytime the user click on advanced search button (all the components were pulled down), I tried to use a Popup, unfortunately, all the drop events are not launched, we can see the visual cue, but cannot deliver "the drop".

 Could you please advise me on what I can do? (Replace Popup for something else? Set some properties to make drag and drop to work...)
 
        <Popup x:Name="popUpMenu" Grid.ColumnSpan="3" Grid.Row="1"
            <telerikNavigation:RadPanelBar x:Name="radPanelBarResultsAndFiltersPanel"  
                                       ExpandMode="Multiple" Visibility="Collapsed" > 
            <telerikNavigation:RadPanelBarItem x:Name="rPanelBarItemFilters" Visibility="Collapsed" Header="Filters"
                <Grid MaxHeight="200"
                    <Grid.ColumnDefinitions> 
                        <ColumnDefinition Width="Auto"/> 
                        <ColumnDefinition Width="*"/> 
                    </Grid.ColumnDefinitions> 
                    <telerikCustom:DraggableTreeView MinWidth="150" MaxWidth="300"  
                                                           Grid.Column="0" Grid.Row="0"  
                                                           IsSingleExpandPath="True"  
                                                           Name="treeEntityTypes"/> 
                        <telerikGridView:RadGridView x:Name="grdFilters"  
                                     RowIndicatorVisibility="Collapsed" AutoGenerateColumns="False"  
                                     CanUserReorderColumns="False" ColumnsWidthMode="Fill"  
                                     telerikDragDrop:RadDragAndDropManager.AllowDrop="True" 
                                     ShowGroupPanel="False" CanUserSortColumns="False"  
                                     Height="175" SelectionChanged="grdFilters_SelectionChanged" > 
 

Except for the popup, all the controls are Telerik.

Thanks ahead for the help,

L. Pinho

11 Answers, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 02 Jun 2009, 12:31 PM
Hello Luis,

Popups open in a separate visual tree and the DragAndDrop does not know about them.

There is a property on the DragDrop options called ParticipatingVisualRoots, which you can use to include the newly opened popup.

I guess you can keep a collection of the popups that you have opened and just add it to this property, for example on a successful drag. This can happen in a DragInfo handler attached to the visual root so that you do not have to worry about it, just keep the popup collection up to date.

We are doing this internally for the popups we open, but unfortunately we do not know when another popup has been opened.

Hopefully this will work in your case.

Sincerely yours,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pinho
Top achievements
Rank 1
answered on 02 Jun 2009, 02:02 PM
Hi Miroslav,

 thanks for the reply:

My "organization" is (pseudo-code):

<Popup> 
  <RadPanelBar> 
    <RadPanelBarItem> 
       <Grid> 
          <Tree Grid.Column="0"
          <RadGridView Grid.Column ="1"
       </Grid> 
   </RadPanelBarItem> 
  </RadPanelBar> 
</Popup> 

I've got a tree and a table, I'm dragging tree items into the table (RadGridView).

So I've followed your suggestion:

        private void DraggableTreeView_DragInfo(object sender, DragDropEventArgs e) 
        { 
            if (!e.Options.ParticipatingVisualRoots.Contains(popUpMenu)) 
                e.Options.ParticipatingVisualRoots.Add(popUpMenu); 
 
            // Drag has completed successfully 
            if (e.Options.Status == DragStatus.DragComplete) 
            { 
                e.Handled = true
            } 
        } 

This drop events still aren't fired, am I doing something wrong?

Thanks again for the help,

L. Pinho
0
Miroslav
Telerik team
answered on 02 Jun 2009, 03:11 PM
Hi Luis,

Strange, I expected that this was the problem.

There are two things that may be going wrong:
1. The drop routed events do not fire at all. To check this, you can add a class handler for

Here you can see how to register a class event handler, just add it for FrameworkElement and not TreeViewItem:

http://www.telerik.com/community/forums/silverlight/drag-and-drop/drop-to-a-datagridrow.aspx#692405

If the handler is not hit at all, then the events are not fired. This may be due to a bug or the ParticipatingVisualRoots not working.

2. The routing of the events is wrong. If you are handling the events somewhere outside of the popup, it is possible that their routing is wrong since the VisualParent of the popup is unexpected. Using the above method you will be able to trace the EventRoute. There is a way to change the event routing if this is the case.

If this does not help, we will be happy to look at a sample project and investigate.

Best wishes,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pinho
Top achievements
Rank 1
answered on 04 Jun 2009, 05:33 PM
Hi Miroslav,

 I'm building an example to sent to you guys. I'll sent it today,

Thanks for the reply,

L. Pinho
0
Pinho
Top achievements
Rank 1
answered on 04 Jun 2009, 10:24 PM
Hi Miroslav,

thanks again for your great support.

I've made an example of what I need:

Drag and drop inside popup

If you could show me what I'm doing wrong, it would be great. Honestly, and I don't understand why, in the example that I've sent to you I couldn't even make the drag'n'drop to work event outside the popup, (altough the DropQuery event was launched, the DropInfo was not - if inside the popup, not even the DropQuery event is launched).

I just need to drag tree view items into a table inside a popup.

Many Thanks,

L. Pinho
0
Accepted
Miroslav
Telerik team
answered on 05 Jun 2009, 10:45 AM
Hello Luis,

First, thanks for the sample project, it really helps to get to the problem quickly. Also, you can always open a support ticket if you want to attach something.

I did not know that you are using Silverlight 3.

There you need to add not the popups but their children in the participating visual roots collection.

Also the drop query is a two-way handshake, i.e. the source can decide to that it does not want to be dropped somewhere. Therefore you need to handle the DragQuery event with status "DropSourceQuery". If you do not want to manage this case, you can add a handler to the root visual in your application that will always return true in this case, then you only need to manage the "DropDestinationQuery".

I modified the project you sent me and I am attaching it here.

I was debugging the application though a remote desktop connection and the drag/drop was lagging a bit. I could not figure out whether this is due to the remote connection or something else. Do you see any noticeable lag?

Please get back to us if you see unexpected issues with Silverlight 3 version of the controls.

Regards,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Pinho
Top achievements
Rank 1
answered on 05 Jun 2009, 11:34 AM
Hi Miroslav,

 what  can I say besides "Excelent", this works great.
 Thanks for the clarification, for the returned solution and for all the help (I'll mark as answer as soon as I commit this reply).

 I don't have any lag at all while running this or dragging the items.

 Sure, I'm always using the latest version, if I find anything I will report it.

Once more, many thanks for the excelent help,

L. Pinho
0
Alex M
Top achievements
Rank 1
answered on 17 Oct 2009, 08:14 PM
Is there a way to make this work for RadScheduler inside a Popup? The DragQuery events don't seem to get called so I cannot add the Popup's child to the ParticipatingVisualRoots.

Thanks

 

0
Miroslav
Telerik team
answered on 20 Oct 2009, 08:12 AM
Hello Alex M,

It is strange that the DragQuery events are not called.

Could you make sure that:
1. The popup has a parent. If you are opening the popup from code (it is not in xaml), could you add it as a child of a panel?
2. You are registering for the DragQuery event using the

visualRoot.AddHandler(RadDragAndDropManager.DragQueryEvent, handler, true);

I expect that if the routed event does not reach the visual root for some reason, you will be able to add a handler to the child of the popup itself where the event should be available.

Does this work in your case?

Kind regards,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
atran
Top achievements
Rank 1
answered on 19 Mar 2014, 12:07 AM
Could you please send me a sample project in WPF?  

I have a RadListBox  inside a Popup window.   I would like to reorder the items inside the RadListBox by drag and drop...    will do more things after drop event completed.
0
Polya
Telerik team
answered on 20 Mar 2014, 01:33 PM
Hello Andy,

Please find attached a sample project containing a ToggleButton and a Popup with a RadListBox. The Popup has its IsOpen property bound to the ToggleButton IsChecked property so the Popup would open only if the ToggleButton is checked. The RadListBox in the Popup allows reorder and drag&drop:

<telerik:RadListBox.DragDropBehavior>
    <telerik:ListBoxDragDropBehavior AllowReorder="True" />
</telerik:RadListBox.DragDropBehavior>
 
...
 
<Style TargetType="telerik:RadListBoxItem" >
    <Setter Property="telerik:DragDropManager.AllowCapturedDrag" Value="True" />
</Style>

Hopefully this helps. If this however does not, please provide more clarifications on what should be achieved.

Regards,
Polya
Telerik
 

Build cross-platform mobile apps using Visual Studio and .NET. Register for the online webinar on 03/27/2014, 11:00AM US ET.. Seats are limited.

 
Tags
DragAndDrop
Asked by
Pinho
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Pinho
Top achievements
Rank 1
Alex M
Top achievements
Rank 1
atran
Top achievements
Rank 1
Polya
Telerik team
Share this question
or