public static IEnumerable <T> Children <T>(this DependencyObject parent, Func <T, bool> predicate, WhereFlags flags) where T : DependencyObject { bool depthFirst = (flags & WhereFlags.DepthFirst) == WhereFlags.DepthFirst; bool recursive = (flags & WhereFlags.Recursive) == WhereFlags.Recursive; bool visualTree = (flags & WhereFlags.VisualTree) == WhereFlags.VisualTree; bool startOnParent = (flags & WhereFlags.StartOnParent) == WhereFlags.StartOnParent; Func <DependencyObject, bool> finalPredicate; if (predicate == null) { finalPredicate = (depObj => depObj is T); } else { finalPredicate = depObj => { T elem = depObj as T; return(elem != null && predicate(elem)); } }; if (visualTree) { if (depthFirst) { return(DepthFirstVisual(parent, startOnParent, recursive, finalPredicate).Cast <T>()); } else { return(BreathFirstVisual(parent, startOnParent, recursive, finalPredicate).Cast <T>()); } } else { if (depthFirst) { return(DepthFirstLogical(parent, startOnParent, recursive, finalPredicate).Cast <T>()); } else { return(BreathFirstLogical(parent, startOnParent, recursive, finalPredicate).Cast <T>()); } } }
public static IEnumerable <T> Children <T>(this DependencyObject parent, string route, WhereFlags flags) where T : DependencyObject { return(Children <T>(parent, p => p.GetRoute() == route, flags)); }
public static IEnumerable <T> Children <T>(this DependencyObject parent, WhereFlags flags) where T : DependencyObject { return(Children <T>(parent, (Func <T, bool>)null, flags)); }
public static T Child <T>(this DependencyObject parent, Func <T, bool> predicate, WhereFlags flags) where T : DependencyObject { return(Children <T>(parent, predicate, flags).FirstEx()); }
public static T Child <T>(this DependencyObject parent, string route, WhereFlags flags) where T : DependencyObject { return(Children <T>(parent, p => p.GetRoute() == route, flags).FirstEx()); }
public static T Child <T>(this DependencyObject parent, WhereFlags flags) where T : DependencyObject { return(Children <T>(parent, (Func <T, bool>)null, flags).FirstEx()); }