private static Func <DependencyObject, bool> GetTemplatedDescendantExpandPredicate(IDataGridItemContainer source) { var fe = source as FrameworkElement; if (fe == null) { throw new ArgumentException("The source object must be a FrameworkElement.", "source"); } return(( DependencyObject item ) => IDataGridItemContainerExtensions.IsPartOfTargetTemplate(item, fe)); }
internal static IEnumerable <IDataGridItemContainer> GetTemplatedChildDataGridItemContainers(this IDataGridItemContainer source) { if (source == null) { throw new ArgumentNullException("source"); } var predicate = IDataGridItemContainerExtensions.GetTemplatedChildExpandPredicate(source); return(IDataGridItemContainerExtensions.GetChildDataGridItemContainers(source, predicate)); }
private static IEnumerable <IDataGridItemContainer> GetChildDataGridItemContainers(IDataGridItemContainer source, Func <DependencyObject, bool> expand) { Debug.Assert(source != null); var root = source as DependencyObject; if (root == null) { throw new ArgumentException("The source object must be a DependencyObject.", "source"); } return(IDataGridItemContainerExtensions.GetChildDataGridItemContainers(root, expand)); }
private static bool IsPartOfTargetTemplate(DependencyObject element, FrameworkElement target) { while (element != null) { var templatedParent = IDataGridItemContainerExtensions.GetTemplatedParent(element); if (templatedParent == target) { return(true); } element = templatedParent; } return(false); }