本文整理汇总了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;
}
示例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;
}