public static Area GetArea (UIElement uielement) { if (uielement == null) return null; if (uielement is Area) return uielement as Area; for (int i = 0; i < uielement.VisualChildrenCount; i++) { var child = GetArea (uielement.GetVisualChild (i) as UIElement); if (child != null) return child; } return null; }
private Area GetArea (Token token, UIElement uielement) { if (uielement == null) return null; if (uielement is FrameworkElement && (uielement as FrameworkElement).DataContext == token) return uielement as Area; for (int i = 0; i < uielement.VisualChildrenCount; i++) { var child = GetArea (token, uielement.GetVisualChild (i) as UIElement); if (child != null) return child; } return null; }