tags:

views:

249

answers:

1

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
Does not work for a Path. Still looking for an answer.Thanks
np