コード例 #1
0
 internal FocusMovement(
     DependencyObject?target,
     FocusMovement copy)
 {
     Target                       = target;
     FocusState                   = copy.FocusState;
     Direction                    = copy.Direction;
     XYFocusOptions               = copy.XYFocusOptions;
     ForceBringIntoView           = copy.ForceBringIntoView;
     AnimateIfBringIntoView       = copy.AnimateIfBringIntoView;
     IsProcessingTab              = copy.IsProcessingTab;
     IsShiftPressed               = copy.IsShiftPressed;
     CanCancel                    = copy.CanCancel;
     CanDepartFocus               = copy.CanDepartFocus;
     CanNavigateFocus             = copy.CanNavigateFocus;
     RaiseGettingLosingEvents     = copy.RaiseGettingLosingEvents;
     ShouldCompleteAsyncOperation = copy.ShouldCompleteAsyncOperation;
     CorrelationId                = copy.CorrelationId;
 }
コード例 #2
0
        internal bool TryHandleTabFocus(bool isShiftDown)
        {
            var direction   = isShiftDown ? FocusNavigationDirection.Previous : FocusNavigationDirection.Next;
            var contentRoot = VisualTree.GetContentRootForElement(_rootVisual);

            if (contentRoot == null)
            {
                return(false);
            }

            contentRoot.InputManager.LastInputDeviceType = InputDeviceType.Keyboard;

            var focusManager  = VisualTree.GetFocusManagerForElement(_rootVisual);
            var focusMovement = new FocusMovement(XYFocusOptions.Default, direction, null);

            focusMovement.IsShiftPressed  = _isShiftDown;
            focusMovement.IsProcessingTab = true;
            var result = focusManager?.FindAndSetNextFocus(focusMovement);

            return(result?.WasMoved == true);
        }