public static ViewFrame GetContainingViewFrame(Control child) { ViewFrame ancestor = null; while ((child != null) && ((ancestor = child as ViewFrame) == null)) { child = child.Parent; } return ancestor; }