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.

 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除非派生类已重写以禁止显示事件,否则,对此属性的值所做的更改通常会引发事件 OnIsKeyboardFocusWithinChangedChanges to the value of this property typically raise the IsKeyboardFocusWithinChanged event, unless a derived class has overridden OnIsKeyboardFocusWithinChanged to suppress the event.

不会直接设置此属性,但可以通过调用 Focus 或发出请求,将焦点设置到元素 MoveFocusYou 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 None