public static void SetFocusToFocusScope(IInputElement newFocus) { UIElement newElementFocus = newFocus as UIElement; if (newElementFocus != null) { UIElement focusScope = FocusManager.GetFocusScope(newElementFocus) as UIElement; int priority = FocusScopeManager.GetFocusScopePriority(focusScope); if (priority != FocusScopeManager.DefaultFocusScopePriority) { FocusScopeManager.Instance.OnScopeKeyboardFocusChanged(focusScope, priority); } } }
private bool IsFocusScopeManaged(UIElement focusScope, int priority, int priorityStartIndex) { for (int curScopeIndex = priorityStartIndex; curScopeIndex < this.scopes.Count; curScopeIndex++) { WeakReference curRef = this.scopes[curScopeIndex]; if (curRef.IsAlive) { UIElement curTarget = (UIElement)curRef.Target; if (FocusScopeManager.GetFocusScopePriority(curTarget) > priority) { return(false); } if (curTarget == focusScope) { return(true); } } } return(false); }
private int FindStartIndexForPriority(int priority) { int startIndex = 0; for (; startIndex < this.scopes.Count; startIndex++) { WeakReference curRef = this.scopes[startIndex]; if (curRef.IsAlive) { if (FocusScopeManager.GetFocusScopePriority((UIElement)curRef.Target) >= priority) { break; } } else { this.listContainsDeadReferences = true; } } return(startIndex); }