public static TAncestorType FindAncestorOrSelf <TAncestorType>(this Visual obj) where TAncestorType : Visual { TAncestorType ancestorType = obj as TAncestorType; if ((object)ancestorType != null) { return(ancestorType); } return(ExtensionMethods.FindAncestor <TAncestorType, DependencyObject>((DependencyObject)obj, new Func <DependencyObject, DependencyObject>(ExtensionMethods.GetVisualOrLogicalParent))); }
public static TAncestorType FindAncestor <TAncestorType>(this Visual obj) where TAncestorType : Visual { return(ExtensionMethods.FindAncestor <TAncestorType, DependencyObject>((DependencyObject)obj, new Func <DependencyObject, DependencyObject>(ExtensionMethods.GetVisualOrLogicalParent))); }