I have a canvas. When I click it, I get the coordinates of the mouse and up (adds a child) has custum control (a thumb with a simply circle) there. On the screen, logically, the upper left corner is taken as reference when adding. I will wish to place the center of thumb exactly where I click (see picture. Red star = Where I click).
To do what, I need to get the actual width and height of the thumb, And Then calculate the exact coordonate to place the center of the thumb where the user clicked. Is there a better way ? In WPF, I used this code, but it doen't work in WinRT.
//Circle in thumb
Ellipse Bdr = this.GetTemplateChild("Forme") as Ellipse;
DependencyObject dobj = VisualTreeHelper.GetParent(Bdr);
Vector ParentPosition = VisualTreeHelper.GetOffset((Visual)VisualTreeHelper.GetParent(dobj));
Vector BdrPosition = VisualTreeHelper.GetOffset((Visual)dobj);
return new Point((Position.X+BdrPosition.X) + Bdr.ActualWidth /2,(Position.Y+ ParentPosition.Y) + Bdr.ActualHeight / 2);
Can you help me ? Thanks !