How can I find the center of a UIElement
in wpf?
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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With