コード例 #1
0
        public static void SetFocusToFocusScope(IInputElement newFocus)
        {
            UIElement uiElement = newFocus as UIElement;

            if (uiElement == null)
            {
                return;
            }
            UIElement focusScope         = FocusManager.GetFocusScope((DependencyObject)uiElement) as UIElement;
            int       focusScopePriority = FocusScopeManager.GetFocusScopePriority((DependencyObject)focusScope);

            if (focusScopePriority == FocusScopeManager.DefaultFocusScopePriority)
            {
                return;
            }
            FocusScopeManager.Instance.OnScopeKeyboardFocusChanged(focusScope, focusScopePriority);
        }
コード例 #2
0
 private bool IsFocusScopeManaged(UIElement focusScope, int priority, int priorityStartIndex)
 {
     for (int index = priorityStartIndex; index < this.scopes.Count; ++index)
     {
         WeakReference weakReference = this.scopes[index];
         if (weakReference.IsAlive)
         {
             UIElement uiElement = (UIElement)weakReference.Target;
             if (FocusScopeManager.GetFocusScopePriority((DependencyObject)uiElement) > priority)
             {
                 return(false);
             }
             if (uiElement == focusScope)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #3
0
        private int FindStartIndexForPriority(int priority)
        {
            int index;

            for (index = 0; index < this.scopes.Count; ++index)
            {
                WeakReference weakReference = this.scopes[index];
                if (weakReference.IsAlive)
                {
                    if (FocusScopeManager.GetFocusScopePriority((DependencyObject)weakReference.Target) >= priority)
                    {
                        break;
                    }
                }
                else
                {
                    this.listContainsDeadReferences = true;
                }
            }
            return(index);
        }