TraversalRequest 类

定义

表示要将焦点移到另一个控件的请求。Represents a request to move focus to another control.

public ref class TraversalRequest
public class TraversalRequest
[System.Serializable]
public class TraversalRequest
type TraversalRequest = class
[<System.Serializable>]
type TraversalRequest = class
Public Class TraversalRequest
继承
TraversalRequest
属性

示例

下面的示例创建一个 TraversalRequest 实例作为调用的输入 FrameworkElement.MoveFocusThe following example creates a TraversalRequest instance as input for a FrameworkElement.MoveFocus call.

// Creating a FocusNavigationDirection object and setting it to a
// local field that contains the direction selected.
FocusNavigationDirection focusDirection = _focusMoveValue;

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

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

// Change keyboard focus.
if (elementWithFocus != null)
{
    elementWithFocus.MoveFocus(request);
}
' Creating a FocusNavigationDirection object and setting it to a
' local field that contains the direction selected.
Dim focusDirection As FocusNavigationDirection = _focusMoveValue

' MoveFocus takes a TraveralReqest as its argument.
Dim request As New TraversalRequest(focusDirection)

' Gets the element with keyboard focus.
Dim elementWithFocus As UIElement = TryCast(Keyboard.FocusedElement, UIElement)

' Change keyboard focus.
If elementWithFocus IsNot Nothing Then
    elementWithFocus.MoveFocus(request)
End If

注解

此类用作方法的输入参数 UIElement.MoveFocusThis class is used as an input parameter for the UIElement.MoveFocus method. MoveFocus方法具有一个 WPF 框架级别重写,它提供了更实用的实现 (FrameworkElement.MoveFocus) ,以及和上的并行实现 ContentElement FrameworkContentElementThe MoveFocus method has a WPF framework-level override that provides a more practical implementation (FrameworkElement.MoveFocus), as well as a parallel implementation on ContentElement and FrameworkContentElement. 你通常会在上设置属性 TraversalRequest ,以便在你请求将焦点移到另一个元素时自定义焦点行为。You typically will set properties on TraversalRequest in order to customize the focusing behavior when you request that the focus be moved to another element.

此类还用作以下方法的输入参数:This class is also used as input parameters for the following methods:

构造函数

TraversalRequest(FocusNavigationDirection)

初始化 TraversalRequest 类的新实例。Initializes a new instance of the TraversalRequest class.

属性

FocusNavigationDirection

获取遍历方向。Gets the traversal direction.

Wrapped

获取或设置一个值,该值指示焦点遍历是否已到达可以具有焦点的最后一个子元素。Gets or sets a value that indicates whether focus traversal has reached the end of child elements that can have focus.

方法

Equals(Object)

确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(继承自 Object)

适用于

另请参阅