private static bool IsValidFocusSubtree(DependencyObject element, bool shouldConsiderXYFocusKeyboardNavigation) { bool isDirectionalRegion = shouldConsiderXYFocusKeyboardNavigation && element is UIElement && IsDirectionalRegion(element); return(FocusProperties.IsVisible(element) && FocusProperties.IsEnabled(element) && !FocusProperties.ShouldSkipFocusSubTree(element) && (!shouldConsiderXYFocusKeyboardNavigation || isDirectionalRegion)); }
internal static bool IsValidCandidate(DependencyObject element) { bool isFocusable = FocusProperties.IsFocusable(element); bool isGamepadFocusCandidate = FocusProperties.IsGamepadFocusCandidate(element); //TODO Uno: RootScrollViewer is not available in Uno yet //bool isRootScrollViewer = element is RootScrollViewer; bool isValidTabStop = FocusProperties.IsPotentialTabStop(element); return(isFocusable && isGamepadFocusCandidate && //!isRootScrollViewer && isValidTabStop); }
internal static List <XYFocus.XYFocusParameters> FindElements( DependencyObject?startRoot, DependencyObject?currentElement, DependencyObject?activeScroller, bool ignoreClipping, bool shouldConsiderXYFocusKeyboardNavigation) { bool isScrolling = (activeScroller != null); List <XYFocus.XYFocusParameters> focusList = new List <XYFocus.XYFocusParameters>(InitialCandidateListCapacity); var collection = FocusProperties.GetFocusChildren(startRoot); if (collection == null) // || collection.IsLeaving()) { return(focusList); } var kidCount = collection.Length; //Iterate though every node in the tree that is focusable for (uint i = 0; i < kidCount; i++) { DependencyObject child = collection[i]; if (child == null) { continue; } bool isEngagementEnabledButNotEngaged = FocusProperties.IsFocusEngagementEnabled(child) && !FocusProperties.IsFocusEngaged(child); //This is an element that can be focused if (child != currentElement && XYFocusFocusability.IsValidCandidate(child)) { var parameters = new XYFocus.XYFocusParameters(); if (isScrolling) { var scrollCandidate = child; var bounds = GetBoundsForRanking(scrollCandidate, ignoreClipping); //Include all elements participating in scrolling or //elements that are currently not occluded (in view) or //elements that are currently occluded but part of a parent scrolling surface. if (IsCandidateParticipatingInScroll(scrollCandidate, activeScroller) || !IsOccluded(scrollCandidate, bounds) || IsCandidateChildOfAncestorScroller(scrollCandidate, activeScroller)) { parameters.Element = scrollCandidate; parameters.Bounds = bounds; focusList.Add(parameters); } } else { var bounds = GetBoundsForRanking(child, ignoreClipping); parameters.Element = child; parameters.Bounds = bounds; focusList.Add(parameters); } } if (IsValidFocusSubtree(child, shouldConsiderXYFocusKeyboardNavigation) && !isEngagementEnabledButNotEngaged) { var subFocusList = FindElements(child, currentElement, activeScroller, ignoreClipping, shouldConsiderXYFocusKeyboardNavigation); focusList.AddRange(subFocusList); } } return(focusList); }