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

How to prevent move a child shape of a RadDiagramContainerShape?

2 Answers 239 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
rick
Top achievements
Rank 1
rick asked on 11 Sep 2018, 06:46 AM

I'm trying to disable moving a child shape of a RadDiagramContainerShape by override DraggingService as below:

public class MyDragging : DraggingService
    {
        private readonly RadDiagram diagram;
 
        public MyDragging(RadDiagram graph)
            : base(graph as IGraphInternal)
        {
            this.diagram = graph;
        }
 
        public override void Drag(Point newPoint)
        {
            if (this.DraggingModels.FirstOrDefault().ParentContainer != null)
            {
                return;
            }
            else
            {
                base.Drag(newPoint);
            }
        }
    }

It does make the child shape immovable. However, after I dragged the child shape, it will be removed from the parent container shape. (subShape.ParentContainer will be null). Then, when I drag the child shape again, it can be moved.

 

How to fix this issue?

2 Answers, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 13 Sep 2018, 08:55 AM
Hi rick,

To prevent a shape to be drag you can set the IsDraggingEnabled property of the shape to false. In your case, you can set this property of the child shape of the container which you don't want to be dragged. Check the following code snippet.
<telerik:RadDiagram>
    <telerik:RadDiagramContainerShape Content="My Shape" Position="100, 100">
        <telerik:RadDiagramShape Content=" Shape 1" Position="120,140" IsDraggingEnabled="False" />
        <telerik:RadDiagramShape Content=" Shape 2" Position="240,140"/>
    </telerik:RadDiagramContainerShape>
</telerik:RadDiagram>

Give this property a try and let me know if it works in your scenario.

Regards,
Dinko
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
rick
Top achievements
Rank 1
answered on 14 Sep 2018, 01:52 AM
wow, works like a charm! thanks very much!
Tags
Diagram
Asked by
rick
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
rick
Top achievements
Rank 1
Share this question
or