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.



除非衍生的類別已覆寫 OnIsKeyboardFocusWithinChanged 以隱藏事件,否則此屬性值的變更通常會引發 IsKeyboardFocusWithinChanged 事件。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
設定為 true 的中繼資料屬性Metadata properties set to true None