Drag and drop with RadWrapPanel

5 posts, 0 answers
  1. Joe
    Joe avatar
    9 posts
    Member since:
    Mar 2009

    Posted 16 Mar 2009 Link to this post


    Is it possible to get drag and drop working with the RadWrapPanel? If so do could you upload a sample of how to get this working?

    I am populating a wrappanel with images and would like to be able to drag those images from the wrappanel onto another control and also drag from the other control onto the images in the wrappanel.

  2. Joe
    Joe avatar
    9 posts
    Member since:
    Mar 2009

    Posted 19 Mar 2009 Link to this post

    I was able to get the dragging working on my controls that are inside the wrappanel. However I had to remove the mouseenter, mouseleave, and mouseleftclick event. I need these events to handle selecting / multi selecting of the items in my wrappanel. Is it possible to have drag and drop work on a custom control that handles these events? Are there any workarounds to get this to work?

  3. DevCraft banner
  4. Miroslav
    Miroslav avatar
    922 posts

    Posted 20 Mar 2009 Link to this post

    Hi Joe,

    Sorry for the delayed reply!

    I prepared a sample solution where drag/drop to a wrap panel is implemented (attached). I do have not handle the case where you drop directly to the panel, but that should be easy enough to implement.

    As for the second question: If you handle the mouse events and there is no other object that the DragDrop can listen to (normally a visual descendant, overlaying the control that handles the events) then there is no workaround for it to work. I.e. if you handle the mouse events of a panel or a rectangle and the panel is empty, the drag drop will not work.

    If you are trying to handle the events of a panel, you can try putting it in an items control (or any other wrapper really and handling the events of the wrapper). The DragDrop uses some tricks to listen to events of children objects (which are normally not handled) but there is no way that it could know about handled events.

    Did the DragDrop work in your specific case? If you provide more info on the particular problem, I may come up with some ideas.

    the Telerik team

    Check out Telerik Trainer , the state of the art learning tool for Telerik products.
  5. Robert Staniskis
    Robert Staniskis avatar
    3 posts
    Member since:
    Apr 2010

    Posted 07 Jul 2010 Link to this post


    I downloaded the sample you posted in this thread and it works well.  Would you be able to modify it so that it supports drop cues?

    Thanks so much,

  6. Tina Stancheva
    Tina Stancheva avatar
    3298 posts

    Posted 12 Jul 2010 Link to this post

    Hello Robert Staniskis,

    You can add a DataTemplate for the DragCue in the Resources of the main page, like so:
    <!-- DragCue Template-->
    <DataTemplate x:Key="DragCueTemplate">
        <TextBlock Text="{Binding Name}"/>

    Then in the OnDragQuery() event handler you can add this DataTemplate as a ContentTemplate for the DragCue, like so:
    private void OnDragQuery(object sender, DragDropQueryEventArgs e)
        if (e.Options.Status == DragStatus.DragQuery)
            var dragCue = RadDragAndDropManager.GenerateVisualCue(sourceControl);
            dragCue.HorizontalAlignment = HorizontalAlignment.Left;
            dragCue.Content = sourceControl.DataContext;
            dragCue.ContentTemplate = this.Resources["DragCueTemplate"] as DataTemplate;
            e.Options.DragCue = dragCue;
            e.Options.Payload = new DragDropOperation() { Payload = sourceControl.DataContext };

    I modified the example accordingly. Please take a look at it and let me know if this is what you had in mind.

    Sincerely yours,
    Tina Stancheva
    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
Back to Top
DevCraft banner