示例#1
0
        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);
                }
            }
        }
示例#2
0
 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);
 }
示例#3
0
        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);
        }