CompleteDragging XY different than Shape XY

2 posts, 1 answers
  1. Dan
    Dan avatar
    8 posts
    Member since:
    Jul 2014

    Posted 06 Feb 2017 Link to this post

    I am getting different XY coordinates on the CompleteDragging event than what the actual shape XY coordinates are (see image file).  Any clue how to get the correct XY coordinates? It seems like I am getting the XY of the center of the shape.  Below is the code I am using:

     

    private void DragService_CompleteDragging(object sender, PositionChangedEventArgs e)
    {
        label13.Text = $"{e.NewPosition.X},{e.NewPosition.Y}";
     
        foreach (var shape in radDiagram1.Shapes)
        {
            var myShape = shape as RadDiagramShape;
            if (myShape.Text == _asset.AssetTag)
            {
                label14.Text = $"{myShape.X},{myShape.Y}";
                break;
            }
        }
    }


  2. Answer
    Dimitar
    Admin
    Dimitar avatar
    2903 posts

    Posted 07 Feb 2017 Link to this post

    Hi Daniel,

    The value of the NewPosition property is calculated depending on the current mouse position. Here is how you can get the shape location:
    private void Ds_CompleteDragging(object sender, PositionChangedEventArgs e)
    {
        var shape = e.Items.ToList()[0] as IShape;
        
        Console.WriteLine("Droped at:" + shape.Position);
    }

    I hope this will be useful. Let me know if you have additional questions.

    Regards,
    Dimitar
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top