UIElement.IsKeyboardFocusWithin 属性

定义

获取一个值,该值指示键盘焦点是否位于元素或其可视化树子元素内的任意位置。Gets a value indicating whether keyboard focus is anywhere within the element or its visual tree child elements. 这是依赖项属性。This is a dependency property.

public:
 property bool IsKeyboardFocusWithin { bool get(); };
public bool IsKeyboardFocusWithin { get; }
member this.IsKeyboardFocusWithin : bool
Public ReadOnly Property IsKeyboardFocusWithin As Boolean

属性值

如果键盘焦点在元素或其子元素上,则为 true;否则为 falsetrue if keyboard focus is on the element or its child elements; otherwise, false.

实现

注解

对此属性的值所做的更改通常引发 IsKeyboardFocusWithinChanged 事件,除非派生类已重写 OnIsKeyboardFocusWithinChanged 以禁止显示该事件。Changes to the value of this property typically raise the IsKeyboardFocusWithinChanged event, unless a derived class has overridden OnIsKeyboardFocusWithinChanged to suppress the event.

不会直接设置此属性,但可以通过调用 Focus或发出 MoveFocus 请求将焦点设置到元素。You do not set this property directly, but you can set the focus to an element by calling Focus, or by making a MoveFocus request. 这两种方法调用可能会更改此属性值。Either of these method calls might change this property value.

IsKeyboardFocusedIsKeyboardFocusWithin 通常用于其他与输入相关的事件的类事件处理程序中,例如,用于确定元素是否已具有键盘焦点,或在鼠标事件和键盘事件一起发生时做出决定。IsKeyboardFocused and IsKeyboardFocusWithin are typically used within class event handlers for other input-related events, for instance to determine whether the element already has keyboard focus, or to make determinations when mouse events and keyboard events occur in conjunction.

依赖项属性信息Dependency Property Information

标识符字段Identifier field IsKeyboardFocusWithinProperty
元数据属性设置为 trueMetadata properties set to true NoneNone

适用于