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

6 posts, 0 answers
  1. Nick Wood
    Nick Wood avatar
    126 posts
    Member since:
    Feb 2010

    Posted 05 May 2011 Link to this post

    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
  2. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 11 May 2011 Link to this post

    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
  3. DevCraft banner
  4. Hans Peter
    Hans Peter avatar
    30 posts
    Member since:
    May 2006

    Posted 19 May 2011 Link to this post

    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

  5. Tobias
    Tobias avatar
    4 posts
    Member since:
    Jul 2012

    Posted 20 Mar 2012 Link to this post

    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

  6. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 21 Mar 2012 Link to this post

    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 >>
  7. Tobias
    Tobias avatar
    4 posts
    Member since:
    Jul 2012

    Posted 21 Mar 2012 Link to this post

    Hi Petar,
    oops - it was the missing import statement, So now everything is working well.
    Thank you for the hint.
    Best regards,
    Tobias
Back to Top
DevCraft banner