当前位置: 首页>>代码示例>>C#>>正文


C# FrameworkElement.PredictFocus方法代码示例

本文整理汇总了C#中System.Windows.FrameworkElement.PredictFocus方法的典型用法代码示例。如果您正苦于以下问题:C# FrameworkElement.PredictFocus方法的具体用法?C# FrameworkElement.PredictFocus怎么用?C# FrameworkElement.PredictFocus使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.FrameworkElement的用法示例。


在下文中一共展示了FrameworkElement.PredictFocus方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ValidateTabKeyHandleIsWithin

    internal bool ValidateTabKeyHandleIsWithin( FrameworkElement originalSource, KeyboardDevice keyboardDevice )
    {
      DependencyObject predictedNextVisual = null;

      //If the original source is not a control (e.g. the cells panel instead of a cell), columns will be used to move focus.
      //In the case of a ListBox set with Cycle or Contained navigation mode, we must move in the other direction if on the first or last item,
      //since PedictFocus will throw is we use FocusNavigationDirection.First/Last.
      if( originalSource != null )
      {
        if( ( keyboardDevice.Modifiers & ModifierKeys.Shift ) == ModifierKeys.Shift )
        {
          predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Left );
          if( predictedNextVisual == null )
          {
            predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Up );
            if( predictedNextVisual == null )
            {
              KeyboardNavigationMode navigationMode = ( KeyboardNavigationMode )originalSource.GetValue( KeyboardNavigation.TabNavigationProperty );
              if( navigationMode == KeyboardNavigationMode.Cycle || navigationMode == KeyboardNavigationMode.Contained )
              {
                predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Right );
                if( predictedNextVisual == null )
                {
                  predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Down );
                }
              }
            }
          }
        }
        else
        {
          predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Right );
          if( predictedNextVisual == null )
          {
            predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Down );
            if( predictedNextVisual == null )
            {
              KeyboardNavigationMode navigationMode = ( KeyboardNavigationMode )originalSource.GetValue( KeyboardNavigation.TabNavigationProperty );
              if( navigationMode == KeyboardNavigationMode.Cycle || navigationMode == KeyboardNavigationMode.Contained )
              {
                predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Left );
                if( predictedNextVisual == null )
                {
                  predictedNextVisual = originalSource.PredictFocus( FocusNavigationDirection.Up );
                }
              }
            }
          }
        }
      }

      if( predictedNextVisual != null )
      {
        Cell ownerCell = Cell.FindFromChild( predictedNextVisual );

        if( ( ownerCell != null ) && ( ownerCell.ParentColumn == this.ParentDataGridControl.CurrentColumn ) )
        {
          if( object.Equals( ownerCell.ParentRow.DataContext, this.ParentDataGridControl.CurrentItemInEdition ) )
            return true;
        }
      }

      return false;
    }
开发者ID:austinedeveloper,项目名称:WpfExtendedToolkit,代码行数:64,代码来源:DataGridItemsHost.cs

示例2: PredictNextElement

    private static DependencyObject PredictNextElement( FrameworkElement source, KeyboardDevice device )
    {
      foreach( var direction in NavigationHelper.GetFocusNavigationDirections( source, device ) )
      {
        var target = source.PredictFocus( direction );
        if( target != null )
          return target;
      }

      return null;
    }
开发者ID:austinedeveloper,项目名称:WpfExtendedToolkit,代码行数:11,代码来源:NavigationHelper.cs


注:本文中的System.Windows.FrameworkElement.PredictFocus方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。