private Rect GetButtonFrame(Button button) { Point topLeft = button.TransformToVisual(ContentPanel).Transform(new Point(0, 0)); return new Rect(topLeft.X, topLeft.Y, button.Width, button.Height); }