When I drop a TextBlock onto a Canvas I use the following code:
var canvas = e.DropTarget as Canvas; var draggedElement = e.OriginalDragSource; FrameworkElement newElement = null; if (draggedElement is TextBlock) { var oldText = draggedElement as TextBlock; newElement = new TextBlock { Text = oldText.Text, TextWrapping = TextWrapping.Wrap, Height = oldText.ActualHeight, Width = oldText.ActualWidth }; } canvas.Children.Add(newElement); Point dropPoint = e.GetPosition(canvas); // Need to get point relative to text as well newElement.SetValue(Canvas.TopProperty, dropPoint.Y); newElement.SetValue(Canvas.LeftProperty, dropPoint.X);
However, the TextBlock is offset as the drop point is the location of the cursor which may be anywhere along the selected text:
Text Being Dragged
^
The same point is returned whether I pass the Canvas or the TextBlock into e.GetPosition.
Good presentation thanks for the helpful blog. Please visit our site for more indepth information -> Dynamics CRM Training | Devops Training | IOT Training | Dell Boomi Training
nice coding...It is correct... Thanks for sharing this valuable information...
<a href="http://www.suryahanaacademy.com/sap-hana-online-training-classes-in-bangalore-india/">SAP HANA Training in Bangalore</a> <a href="http://www.suryahanaacademy.com/hana-cource-content/">course content </a> <a href="http://www.suryahanaacademy.com/sap-hana-online-training-classes-in-bangalore-india/">SAP HANA TRAINING IN BANGALORE </a> <a href="http://www.suryahanaacademy.com/sap-hana-training-in-hyderabad/">SAP HANA ONLINE TRAINING IN HYDERABAD </a>
<a href="http://www.suryahanaacademy.com/sap-hana-online-training-classes-in-bangalore-india/">SAP HANA ONLINE TRAINING IN BANGALORE </a>
http://www.suryahanaacademy.com/sap-hana-online-training-classes-in-bangalore-india/
http://www.suryahanaacademy.com/sap-hana-training-in-hyderabad/
I start from a PHP/CakePHP, JQuery, establishment. I'm searching for proposal direction for Drag and Drop frameworks for desktop based program based web applications, in spite of the way that I'm keen on decisions that are in like manner neighborly with telephone hole compact applications.
Php Training institute in delhi
I originate from a PHP/CakePHP, JQuery, foundation. I'm looking for suggestion guidance for Drag and Drop systems for desktop based program based web applications, despite the fact that I'm interested in choices that are likewise neighborly with phonegap portable applications.Dot Net Training in Chennai