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

Not Fired: RadDragAndDropManager.AddDragQueryHandler(this.treeSource, OnDragQuery);

5 Answers 188 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Nick Wood
Top achievements
Rank 1
Nick Wood asked on 06 May 2011, 12:36 AM
Hi All,

I have the following code that was working in the Q3 2010 bins, but now on the Q1 2011 version (2011.1.419.1040), I cannot get drag manager QueryHandler event to fire: RadDragAndDropManager.AddDragQueryHandler(this.treeSource, OnDragQuery);

Full code:

public partial class AddEditPlaylist : ChildWindow
    {
        private AddEditPlaylistViewModel _VM;
        public AddEditPlaylistViewModel VM
        {
            get
            {
                return _VM;
            }
            set
            {
                _VM = value;
            }
        }
  
        public AddEditPlaylist(Playlists EditPlaylist)
        {
            InitializeComponent();
  
            RadDragAndDropManager.AddDragQueryHandler(this.treeSource, OnDragQuery);
            RadDragAndDropManager.AddDragQueryHandler(this.treeViewTarget, OnDragQuery);
  
            Guid EditPlaylistId = Guid.Empty;
            if (EditPlaylist != null) { EditPlaylistId = EditPlaylist.PlaylistId; }
  
            this.VM = new AddEditPlaylistViewModel(EditPlaylistId);
            this.VM.ResultHandler = result => { if (result.HasValue) { this.DialogResult = result.Value; } };
            this.DataContext = this.VM;
        }
  
        private void OnDragQuery(object sender, DragDropQueryEventArgs e)
        {
            if (e.Options.ParticipatingVisualRoots.Contains(this) == false)
                e.Options.ParticipatingVisualRoots.Add(this);
        }
  
        private void treeViewTarget_PreviewDragEnded(object sender, Telerik.Windows.Controls.RadTreeViewDragEndedEventArgs e)
        {
  
        }
    }


As you can see, I am running this in a ChildWindow and as a result, I need to set:
e.Options.ParticipatingVisualRoots.Add(this);
In order for the PreviewDragEnded event to be fired.

Is the some change or some reason why this code would not be working now in the latest binaries?

Nick

5 Answers, 1 is accepted

Sort by
0
Petar Mladenov
Telerik team
answered on 11 May 2011, 01:42 PM
Hi Nick Wood,

We managed to reproduce this issue at our side. It appears that the RadTreeView handles these events internally , so you have to wire for them in another way like so:
this.lefttree.AddHandler(RadDragAndDropManager.DragQueryEvent, new EventHandler<DragDropQueryEventArgs>(OnDragQuery), true);
The third parameter in this constructor specifies that handled events will be fired.
You can also check out the attached project  where this is realized.

Kind regards,
Petar Mladenov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Hans Peter
Top achievements
Rank 1
answered on 19 May 2011, 09:09 AM
EDIT: Sorry I have just found the thread and didn't noticed, that it is in the Silverlight/Treeview-Forum. My Problem appears in WPF. I'll repost it in the right forum.

Hi,

I have the same problem and I tried your solution. Do you have any idea, what could cause the strange behavior shown in the screenshot? I have two RadTreeListView side by side and I want to drag&drop items from the one side to the other.

Hans

0
Tobias
Top achievements
Rank 1
answered on 20 Mar 2012, 03:46 PM
Hi Petar,
for my solution I translated the C# code

    
this.lefttree.AddHandler(RadDragAndDropManager.DragQueryEvent,
new EventHandler<DragDropQueryEventArgs>(OnDragQuery), true);
     

to VB
    
myradtreeview.AddHandler(RadDragAndDropManager.DragQueryEvent, 
New EventHandler(Of DragDropQueryEventArgs)(AddressOf OnMyRadTreeViewDragQuery), True
)
     

    
but I receive the following error:

    Overload resolution failed because no accessible 'AddHandler' can be called with these arguments:
    'Public Sub AddHandler(routedEvent As System.Windows.RoutedEvent, handler As System.Delegate, handledEventsToo As Boolean)': Value of type 'Telerik.Windows.RoutedEvent' cannot be converted to 'System.Windows.RoutedEvent'.
Extension method 'Public Sub AddHandler(routedEvent As Microsoft.Windows.ExtendedRoutedEvent, handler As System.Delegate, handledEventsToo As Boolean)' defined in 'System.Windows.UIElementExtendedRoutedEventExtensions': Value of type 'Telerik.Windows.RoutedEvent' cannot be converted to 'Microsoft.Windows.ExtendedRoutedEvent'.
 

Can you give me a hint, what I have done wrong?
Tobias

0
Petar Mladenov
Telerik team
answered on 21 Mar 2012, 07:57 AM
Hello Tobias,

 Could you please confirm that you have properly imported Telerik.Windows and the event is defined like:

' OnDragQuery event handler Private Sub OnDragQuery(ByVal sender As Object, ByVal e As DragDropQueryEventArgs) End Sub
Please check out this help article and let us know if it helps you.

Regards,
Petar Mladenov
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
Tobias
Top achievements
Rank 1
answered on 21 Mar 2012, 08:57 AM
Hi Petar,
oops - it was the missing import statement, So now everything is working well.
Thank you for the hint.
Best regards,
Tobias
Tags
TreeView
Asked by
Nick Wood
Top achievements
Rank 1
Answers by
Petar Mladenov
Telerik team
Hans Peter
Top achievements
Rank 1
Tobias
Top achievements
Rank 1
Share this question
or