Пример #1
0
        protected virtual void HandlePreviewTabKey(KeyEventArgs e)
        {
            if (e.Handled)
            {
                return;
            }

            DataGridContext dataGridContext = DataGridControl.GetDataGridContext(this);

            if (dataGridContext == null)
            {
                return;
            }

            DataGridContext currentDataGridContext = dataGridContext.DataGridControl.CurrentContext;

            if (currentDataGridContext == null)
            {
                return;
            }

            DependencyObject container = currentDataGridContext.GetContainerFromItem(currentDataGridContext.InternalCurrentItem);

            if (container != null)
            {
                KeyboardNavigationMode tabbingMode = KeyboardNavigation.GetTabNavigation(container);

                if (tabbingMode != KeyboardNavigationMode.None)
                {
                    if ((Keyboard.Modifiers == ModifierKeys.None) || (Keyboard.Modifiers == ModifierKeys.Shift))
                    {
                        DataGridItemsHost.BringIntoViewKeyboardFocusedElement();

                        //Force the "inline" relayout of the panel
                        //This has no effect if the panel do not have to be updated.
                        this.UpdateLayout();
                    }
                }
            }
        }
Пример #2
0
        internal static UIElement GetItemsHostContainerFromElement(DataGridItemsHost itemsHost, DependencyObject element)
        {
            UIElement uiElement = element as UIElement;

            // If the focused element is not a UIElement (e.g. : Hyperlink), we go up until we find one.
            while ((uiElement == null) && (element != null))
            {
                element   = TreeHelper.GetParent(element);
                uiElement = element as UIElement;
            }

            if (uiElement == null)
            {
                return(null);
            }

            // Try to do a Contains before enumerating
            // to avoid manually enumerating if we
            // already have a container
            if (itemsHost.Children.Contains(uiElement))
            {
                return(uiElement);
            }
            else
            {
                foreach (UIElement container in itemsHost.Children)
                {
                    if (container.IsAncestorOf(uiElement))
                    {
                        return(container);
                    }
                }
            }

            return(null);
        }
Пример #3
0
 protected virtual void HandleRightKey(KeyEventArgs e)
 {
     e.Handled = DataGridItemsHost.ProcessMoveFocus(e.Key);
 }
Пример #4
0
 protected virtual void HandlePreviewDownKey(KeyEventArgs e)
 {
     DataGridItemsHost.BringIntoViewKeyboardFocusedElement();
     this.UpdateLayout();
 }