How to find the center of a uielement in wpf. Thanks N
A:
You can get absolute position of the control like this
Point relativePoint = myVisual.TransformToAncestor(rootVisual)
.Transform(new Point(0, 0));
where myVisual
is your control and rootVisual
is the parent control(see Get Absolute Position of element within the window in wpf), so you can find the center of the uielement like this
Point pt = new Point(relativePoint.X + myVisual.ActualWidth/2, relativePoint.Y + myVisual.ActualHeight/2);
ArsenMkrt
2009-10-09 05:54:45
Does not work for a Path. Still looking for an answer.Thanks
np
2009-12-03 12:27:51