Dragging/Moving a RadDiagramShape on RadDiagram

4 posts, 1 answers
  1. Karandeep Singh
    Karandeep Singh avatar
    4 posts
    Member since:
    May 2010

    Posted 13 Aug 2012 Link to this post

    I have been creating and adding RadDiagramShape to the RadDiagram control at run time.
    I wan to detect/capture the event whenever the shape is moved(dragged to change its position) on the RadDiagram control.
    How can I do that?

    I tried to do something like 
    radShape.DragEnter += OnShapePositionChanged;


    also tried
    radShape.AddHandler(RadDragAndDropManager.DragQueryEvent, new EventHandler<DragDropQueryEventArgs>(OnShapePositionChanged));

    Didn't work.
    Help
  2. Answer
    Miro Miroslavov
    Admin
    Miro Miroslavov avatar
    588 posts

    Posted 14 Aug 2012 Link to this post

    Hi Karandeep Singh,

     You can handle the RadDiagram.PreviewDrag event as well as the RadDiagram.DragEvent. The first one occurs right after the drag has started (you can also handle it and stop the drag), while the second event is raised the drag has ended (the mouse is released).
    Please let us know if these events work for you. 

    Kind regards,
    Miro Miroslavov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
  4. Thiruvengadam
    Thiruvengadam avatar
    1 posts
    Member since:
    Sep 2015

    Posted 11 Sep 2015 in reply to Miro Miroslavov Link to this post

    How can I access the below using the DragEvent.

     1.  The Item that is Dropped.

    2. The Item within which the Item is Dropped.

     for (e.g) If I am dropping a shape "Fruit" inside a container "Basket", how do I get the "Fruit" and "Basket"?

  5. Milena
    Admin
    Milena avatar
    204 posts

    Posted 16 Sep 2015 Link to this post

    Hello Thiruvengadam,

    As my colleague Peter explained you in another thread -  container shapes (the "Basket" I suppose) only visually contains other shapes / containers. The child shapes reside in the Children collection of the ContainerShape, but their parent is actually the Diagram. However, if you need to detect when a shape ("Fruit") is dropped in Container Shape ("Basket") - you can inherit the RadDiagramContainerShape class and override the OnItemsCollectionChanged event:
    public class CustomContainerShape : RadDiagramContainerShape
    {
        protected override void OnItemsCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            base.OnItemsCollectionChanged(sender, e);
        }
    }

    You can get the item/s which is/are dropped inside the container from event arguments - e.NewItems collection.

    I hope this information helps.

    Regards,
    Milena
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top