當前位置: 首頁>>代碼示例>>C#>>正文


C# Input.TraversalRequest類代碼示例

本文整理匯總了C#中System.Windows.Input.TraversalRequest的典型用法代碼示例。如果您正苦於以下問題:C# TraversalRequest類的具體用法?C# TraversalRequest怎麽用?C# TraversalRequest使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TraversalRequest類屬於System.Windows.Input命名空間,在下文中一共展示了TraversalRequest類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnPreviewKeyDown

        private static void OnPreviewKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Enter)
            {
                if (GetFocusNext((UIElement)sender))
                {
                    TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
                    UIElement keyboardFocus = Keyboard.FocusedElement as UIElement;

                    if (keyboardFocus != null)
                    {
                        keyboardFocus.MoveFocus(tRequest);
                    }
                }
                else if (GetFocusedControl((UIElement)sender) != null)
                {
                    var ctl = GetFocusedControl((UIElement)sender);
                    if (ctl != null && ctl is IInputElement)
                    {
                        FocusManager.SetFocusedElement(ctl, (IInputElement)ctl);
                    }
                }
                e.Handled = true;
            }
        }
開發者ID:nagyistoce,項目名稱:ArchitectureCampSample,代碼行數:25,代碼來源:EnterToTabBehavior.cs

示例2: TabIntoCore

		protected override Boolean TabIntoCore(TraversalRequest request)
		{
			if (this.m_GotFocus != null)
			{
				this.m_GotFocus(this, EventArgs.Empty);
			}
			return true;
		}
開發者ID:Happy-Ferret,項目名稱:dotgecko,代碼行數:8,代碼來源:WebBrowserElement.cs

示例3: OnPreviewMouseLeftButtonDown

 private void OnPreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     var row = sender as DataGridRow;
     row.Focusable = true;
     bool focused = row.Focus();
     TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
     UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;
     if (elementWithFocus != null)
         elementWithFocus.MoveFocus(request);
 }
開發者ID:ponraja,項目名稱:Regex-Builder,代碼行數:10,代碼來源:LibraryView.xaml.cs

示例4: Window_Loaded

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            FocusManager.SetFocusedElement(this, tb);
            TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
            UIElement keyboardFocus = Keyboard.FocusedElement as UIElement;

            if (keyboardFocus != null)
            {
                keyboardFocus.MoveFocus(tRequest);
            }
        }
開發者ID:madd0,項目名稱:MoveToFolder,代碼行數:11,代碼來源:FolderSelectionWindow.xaml.cs

示例5: KeyUp_TextBox

        void KeyUp_TextBox(object sender, KeyEventArgs e)
        {
            var tb = e.OriginalSource as TextBox;
            if (tb == null)
            {
                return;
            }

            if (e.Key == Key.Return || e.Key == Key.Enter)
            {
                var req = new TraversalRequest(FocusNavigationDirection.Next);
                tb.MoveFocus(req);
            }
        }
開發者ID:mrange,項目名稱:WordFinder,代碼行數:14,代碼來源:MainWindow.xaml.cs

示例6: OnMoveFocus

        private void OnMoveFocus(object sender, RoutedEventArgs e)
        {
            // Creating a FocusNavigationDirection object and setting it to a
            // local field that contains the direction selected.
            var focusDirection = _focusMoveValue;

            // MoveFocus takes a TraveralReqest as its argument.
            var request = new TraversalRequest(focusDirection);

            // Gets the element with keyboard focus.
            var elementWithFocus = Keyboard.FocusedElement as UIElement;

            // Change keyboard focus.
            elementWithFocus?.MoveFocus(request);
        }
開發者ID:ClemensT,項目名稱:WPF-Samples,代碼行數:15,代碼來源:MainWindow.cs

示例7: MoveToNextUIElement

        private static void MoveToNextUIElement(KeyEventArgs e)
        {
            // Creating a FocusNavigationDirection object and setting it to a
            // local field that contains the direction selected.
            const FocusNavigationDirection focusDirection = FocusNavigationDirection.Next;

            // MoveFocus takes a TraveralReqest as its argument.
            var request = new TraversalRequest(focusDirection);

            // Gets the element with keyboard focus.
            var elementWithFocus = Keyboard.FocusedElement as UIElement;

            // Change keyboard focus.
            if (elementWithFocus == null) return;
            if (elementWithFocus.MoveFocus(request)) e.Handled = true;
        }
開發者ID:starlest,項目名稱:PJSM.ERP,代碼行數:16,代碼來源:PurchaseView.xaml.cs

示例8: CreateDynamicEditingElement

        protected override FrameworkElement CreateDynamicEditingElement(Entity curEntity)
        {
            var value = this.PropertyValue;

            //支持兩種屬性類型:DateRange,String,所以這裏使用這個變量進行分辨
            var useDateRangeType = this.Meta.PropertyMeta.Runtime.PropertyType == typeof(DateRange);

            var range = useDateRangeType ?
                new DateRange(value as DateRange) :
                DateRange.Parse(value != null ? value as string : string.Empty);

            var control = new DateRangePropertyEditorControl(range);
            control.Confirm += (oo, ee) =>
            {
                if (useDateRangeType)
                {
                    var raw = value as DateRange;
                    raw.BeginValue = ee.Range.BeginValue;
                    raw.EndValue = ee.Range.EndValue;
                }
                else
                {
                    this.PropertyValue = ee.Range.ToString();
                }
            };

            control.KeyDown += (oo, ee) =>
            {
                if (ee.Key == Key.Enter)
                {
                    FocusNavigationDirection focusDirection = FocusNavigationDirection.Next;
                    TraversalRequest request = new TraversalRequest(focusDirection);
                    control.MoveFocus(request);
                }
            };

            this.AddReadOnlyComponent(control);

            this.SetAutomationElement(control);

            return control;
        }
開發者ID:569550384,項目名稱:Rafy,代碼行數:42,代碼來源:DateRangePropertyEditor.cs

示例9: Merlin_DataContextChanged

 void Merlin_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e)
 {
     if (e.NewValue is QueryEditorModel)
     {
         QueryEditorModel model = e.NewValue as QueryEditorModel;
         model.BuildStartCommand.CanExecuteTargets += () => true;
         model.BuildStartCommand.ExecuteTargets += (o) =>
         {
             // Source doesn't get updated for we need to move the
             // focus out for the bind to the source.
             TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
             UIElement element = Keyboard.FocusedElement as UIElement;
             if (element != null)
             {
                 element.MoveFocus(request);
                 element.Focus();
             }
         };
     }
 }
開發者ID:aelij,項目名稱:svcperf,代碼行數:20,代碼來源:Merlin.xaml.cs

示例10: Find_KeyUp

 private void Find_KeyUp(object sender, KeyEventArgs e)
 {
     if (e.Key == Key.Enter)
     {
         ComboBox comboBox = ((ComboBox)sender);
         if (comboBox.Text.Length > 0 && comboBox.Items != null && (comboBox.Items.Count == 0 || (string)comboBox.Items[0] != comboBox.Text))
         {
             comboBox.Items.Insert(0, comboBox.Text);
         }
         TraversalRequest tRequest = new TraversalRequest(FocusNavigationDirection.Next);
         UIElement keyboardFocus = Keyboard.FocusedElement as UIElement;
         if (keyboardFocus != null)
         {
             keyboardFocus.MoveFocus(tRequest);
         }
     }
     else
     {
         mainWindow.FindNextStringOnPage(FindText.Text, false, true, this.MatchCase.IsChecked ?? true, this.RegexFind.IsChecked ?? true);
     }
 }
開發者ID:kjk,項目名稱:kjkpub,代碼行數:21,代碼來源:FindAndReplace.xaml.cs

示例11: TextBox_TextChanged

 private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
 {
     TextBox textbox = (TextBox)sender;
     byte octet;
     if(!byte.TryParse(textbox.Text,out octet))
     {
         textbox.Text = "";
     }
     else
     {
         if (textbox.Text.Length == 3)
         {
             TraversalRequest request = new TraversalRequest(FocusNavigationDirection.Next);
             request.Wrapped = true;
             textbox.MoveFocus(request);
         }
     }
     if(firstOctet.Text!="" && secondOctet.Text!="" && thirdOctet.Text!="" && fourthOctet.Text != "")
     {
         calculate();
     }
     IPCalculation ipc = new IPCalculation(null, 1);
 }
開發者ID:subnetz,項目名稱:IPCalc,代碼行數:23,代碼來源:MainWindow.xaml.cs

示例12: Weekdays_PreviewKeyDown

        private void Weekdays_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e)
        {

            Action<FocusNavigationDirection> moveFocus = focusDirection =>
            {
                e.Handled = true;
                var request = new TraversalRequest(focusDirection);

                var focusedElement = Keyboard.FocusedElement as CheckBox;
                if (((string)focusedElement.Content == "SU" && request.FocusNavigationDirection == FocusNavigationDirection.Next))
                {
                    Monday.Focus();
                }
                else if (((string)focusedElement.Content == "MO" && request.FocusNavigationDirection == FocusNavigationDirection.Previous))
                {
                    Sunday.Focus();
                }
                else
                {
                    focusedElement.MoveFocus(request);
                }                
            };

            if (e.Key == Key.Down)
            {
                moveFocus(FocusNavigationDirection.Previous);
            }             
            else if (e.Key == Key.Up)
            {
                moveFocus(FocusNavigationDirection.Next);
            }           
            if (e.Key == Key.Tab)
            {
                Sunday.Focus();
            }              
        }
開發者ID:Aishaj,項目名稱:AGC.v3,代碼行數:36,代碼來源:EventsCreateView.xaml.cs

示例13: TabIntoCore

 bool IKeyboardInputSink.TabInto(TraversalRequest request)
 {
     return TabIntoCore(request);
 }
開發者ID:JazzFisch,項目名稱:AnotherCombatManager,代碼行數:4,代碼來源:RedirectedHwndHost.cs

示例14: OnTabKeyDown

        /// <summary>
        ///     Called when the tab key is pressed to perform focus navigation.
        /// </summary>
        private void OnTabKeyDown(KeyEventArgs e)
        {
            // When the end-user uses the keyboard to tab to another cell while the current cell
            // is in edit-mode, then the next cell should enter edit mode in addition to gaining
            // focus. There is no way to detect this from the focus change events, so the cell
            // is going to handle the complete operation manually.
            // The standard focus change method is being called here, so even if focus moves
            // to something other than a cell, focus should land on the element that it would
            // have landed on anyway.
            DataGridCell currentCellContainer = CurrentCellContainer;
            if (currentCellContainer != null)
            {
                bool wasEditing = currentCellContainer.IsEditing;
                bool previous = ((e.KeyboardDevice.Modifiers & ModifierKeys.Shift) == ModifierKeys.Shift);

                // Start navigation from the current focus to allow moveing focus on other focusable elements inside the cell
                UIElement startElement = Keyboard.FocusedElement as UIElement;
                ContentElement startContentElement = (startElement == null) ? Keyboard.FocusedElement as ContentElement : null;
                if ((startElement != null) || (startContentElement != null))
                {
                    e.Handled = true;

                    FocusNavigationDirection direction = previous ? FocusNavigationDirection.Previous : FocusNavigationDirection.Next;
                    TraversalRequest request = new TraversalRequest(direction);

                    // Move focus to the the next or previous tab stop.
                    if (((startElement != null) && startElement.MoveFocus(request)) ||
                        ((startContentElement != null) && startContentElement.MoveFocus(request)))
                    {
                        // If focus moved to the cell while in edit mode - keep navigating to the previous cell
                        if (wasEditing && previous && Keyboard.FocusedElement == currentCellContainer)
                        {
                            currentCellContainer.MoveFocus(request);
                        }

                        // In case of grouping if a row level commit happened due to
                        // the previous focus change, the container of the row gets
                        // removed from the visual tree by the CollectionView,
                        // but we still hang on to a cell of that row, which will be used
                        // by the call to SelectAndEditOnFocusMove. Hence re-establishing the
                        // focus appropriately in such cases.
                        if (IsGrouping && wasEditing)
                        {
                            DataGridCell newCell = GetCellForSelectAndEditOnFocusMove();

                            if (newCell != null &&
                                newCell.RowDataItem == currentCellContainer.RowDataItem)
                            {
                                DataGridCell realNewCell = TryFindCell(ItemInfoFromContainer(newCell.RowOwner), newCell.Column);

                                // Forcing an UpdateLayout since the generation of the new row
                                // container which was removed earlier is done in measure.
                                if (realNewCell == null)
                                {
                                    UpdateLayout();
                                    realNewCell = TryFindCell(ItemInfoFromContainer(newCell.RowOwner), newCell.Column);
                                }
                                if (realNewCell != null && realNewCell != newCell)
                                {
                                    realNewCell.Focus();
                                }
                            }
                        }

                        // When doing TAB and SHIFT+TAB focus movement, don't confuse the selection
                        // code, which also relies on SHIFT to know whether to extend selection or not.
                        SelectAndEditOnFocusMove(e, currentCellContainer, wasEditing, /* allowsExtendSelect = */ false, /* ignoreControlKey = */ true);
                    }
                }
            }
        }
開發者ID:JianwenSun,項目名稱:cc,代碼行數:74,代碼來源:DataGrid.cs

示例15: OnArrowKeyDown


//.........這裏部分代碼省略.........
                                }
                                else
                                {
                                    nextDisplayIndex--;
                                    while (nextDisplayIndex >= 0)
                                    {
                                        DataGridColumn column = ColumnFromDisplayIndex(nextDisplayIndex);
                                        if (column.IsVisible)
                                        {
                                            break;
                                        }

                                        nextDisplayIndex--;
                                    }

                                    if (nextDisplayIndex < 0)
                                    {
                                        if (keyboardNavigationMode == KeyboardNavigationMode.Cycle)
                                        {
                                            nextDisplayIndex = InternalColumns.LastVisibleDisplayIndex;
                                        }
                                        else if (keyboardNavigationMode == KeyboardNavigationMode.Contained)
                                        {
                                            DependencyObject nextFocusTarget = keyboardNavigation.PredictFocusedElement(currentCellContainer, KeyToTraversalDirection(rtlKey),
                                                treeViewNavigation:false, considerDescendants:false);
                                            if (nextFocusTarget != null && keyboardNavigation.IsAncestorOfEx(this, nextFocusTarget))
                                            {
                                                Keyboard.Focus(nextFocusTarget as IInputElement);
                                            }
                                            return;
                                        }
                                        else // Continue, Local, None - move focus out of the datagrid
                                        {
                                            MoveFocus(new TraversalRequest(e.Key == Key.Left ? FocusNavigationDirection.Left : FocusNavigationDirection.Right));
                                            return;
                                        }
                                    }
                                }

                                break;

                            case Key.Right:
                                if (controlModifier)
                                {
                                    nextDisplayIndex = Math.Max(0, InternalColumns.LastVisibleDisplayIndex);
                                }
                                else
                                {
                                    nextDisplayIndex++;
                                    int columnCount = Columns.Count;
                                    while (nextDisplayIndex < columnCount)
                                    {
                                        DataGridColumn column = ColumnFromDisplayIndex(nextDisplayIndex);
                                        if (column.IsVisible)
                                        {
                                            break;
                                        }

                                        nextDisplayIndex++;
                                    }

                                    if (nextDisplayIndex >= Columns.Count)
                                    {
                                        if (keyboardNavigationMode == KeyboardNavigationMode.Cycle)
                                        {
                                            nextDisplayIndex = InternalColumns.FirstVisibleDisplayIndex;
開發者ID:JianwenSun,項目名稱:cc,代碼行數:67,代碼來源:DataGrid.cs


注:本文中的System.Windows.Input.TraversalRequest類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。