private TabStopProcessingResult ProcessTabStopInternal( DependencyObject?pCandidateTabStop, bool isBackward, bool didCycleFocusAtRootVisualScope) { var spCurrent = this; var result = new TabStopProcessingResult(); while (spCurrent != null && !(result.IsOverriden)) { result = spCurrent.ProcessTabStopOverride( this, pCandidateTabStop, isBackward, didCycleFocusAtRootVisualScope); var spParent = VisualTreeHelper.GetParent(spCurrent); spCurrent = spParent as UIElement; } return(result); }
private TabStopProcessingResult ProcessCandidateTabStopInternal( DependencyObject?pCurrentTabStop, DependencyObject?pOverriddenCandidateTabStop, bool isBackward) { var spCurrent = this; var result = new TabStopProcessingResult(); while (spCurrent != null && !(result.IsOverriden)) { result = spCurrent.ProcessCandidateTabStopOverride( pCurrentTabStop, this, pOverriddenCandidateTabStop, isBackward); var spParent = VisualTreeHelper.GetParent(spCurrent); spCurrent = spParent as UIElement; } return(result); }
internal TabStopProcessingResult ProcessTabStop( DependencyObject?pFocusedElement, DependencyObject?pCandidateTabStopElement, bool isBackward, bool didCycleFocusAtRootVisualScope) { DependencyObject?spFocusedTarget = null; DependencyObject?spCandidateTarget = null; DependencyObject?spFocusedTargetParent = null; DependencyObject?spCandidateTargetParent = null; UIElement? spFocusedTargetAsUIE = null; UIElement? spCandidateTargetAsUIE = null; UIElement? spNewCandidateTargetAsUIE = null; var tabStopProcessingResult = new TabStopProcessingResult(); var candidateTabStopProcessingResult = new TabStopProcessingResult(); if (pFocusedElement != null) { spFocusedTarget = pFocusedElement; spFocusedTargetAsUIE = spFocusedTarget as UIElement; // Get the parent if it is not a UIElement. (E.g. Hyperlink) if (spFocusedTargetAsUIE == null) { spFocusedTargetParent = VisualTreeHelper.GetParent(spFocusedTarget); spFocusedTargetAsUIE = spFocusedTargetParent as UIElement; } } if (pCandidateTabStopElement != null) { spCandidateTarget = pCandidateTabStopElement; spCandidateTargetAsUIE = spCandidateTarget as UIElement; // Get the parent if it is not a UIElement. (E.g. Hyperlink) if (spCandidateTargetAsUIE == null) { spCandidateTargetParent = VisualTreeHelper.GetParent(spCandidateTarget); spCandidateTargetAsUIE = spCandidateTargetParent as UIElement; } } MUX_ASSERT(tabStopProcessingResult.NewTabStop == null); if (spFocusedTargetAsUIE != null) { tabStopProcessingResult = spFocusedTargetAsUIE.ProcessTabStopInternal(spCandidateTarget, isBackward, didCycleFocusAtRootVisualScope); } if (!tabStopProcessingResult.IsOverriden && spCandidateTargetAsUIE != null) { MUX_ASSERT(tabStopProcessingResult.NewTabStop == null); var candidateResult = spCandidateTargetAsUIE.ProcessCandidateTabStopInternal( spFocusedTarget, null, isBackward); tabStopProcessingResult.NewTabStop = candidateResult.NewTabStop; tabStopProcessingResult.IsOverriden = candidateResult.IsOverriden; } else if (tabStopProcessingResult.IsOverriden && tabStopProcessingResult.NewTabStop != null) { spNewCandidateTargetAsUIE = tabStopProcessingResult.NewTabStop as UIElement; if (spNewCandidateTargetAsUIE != null) { candidateTabStopProcessingResult = spNewCandidateTargetAsUIE.ProcessCandidateTabStopInternal( spFocusedTarget, tabStopProcessingResult.NewTabStop, isBackward); } } if (!tabStopProcessingResult.IsOverriden && !candidateTabStopProcessingResult.IsOverriden) { // Process TabStop if the application bar service is available. var spApplicationBarService = DXamlCore.Current.TryGetApplicationBarService(); if (spApplicationBarService != null) { var appBarResult = spApplicationBarService.ProcessTabStopOverride( spFocusedTarget, spCandidateTarget, isBackward); tabStopProcessingResult.NewTabStop = appBarResult.NewTabStop; tabStopProcessingResult.IsOverriden = appBarResult.IsOverriden; if (tabStopProcessingResult.IsOverriden && tabStopProcessingResult.NewTabStop != null) { spNewCandidateTargetAsUIE = tabStopProcessingResult.NewTabStop as UIElement; if (spNewCandidateTargetAsUIE != null) { candidateTabStopProcessingResult = spNewCandidateTargetAsUIE.ProcessCandidateTabStopInternal( spFocusedTarget, tabStopProcessingResult.NewTabStop, isBackward); } } } } var result = new TabStopProcessingResult(); if (candidateTabStopProcessingResult.IsOverriden) { if (candidateTabStopProcessingResult.NewTabStop != null) { result.NewTabStop = candidateTabStopProcessingResult.NewTabStop; } result.IsOverriden = true; } else if (tabStopProcessingResult.IsOverriden) { if (tabStopProcessingResult.NewTabStop != null) { result.NewTabStop = tabStopProcessingResult.NewTabStop; } result.IsOverriden = true; } return(result); }