UIElement.IsKeyboardFocusWithin UIElement.IsKeyboardFocusWithin UIElement.IsKeyboardFocusWithin UIElement.IsKeyboardFocusWithin Property


取得值,表示鍵盤焦點是否在項目或其視覺化樹狀結構子項目內的任何位置。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事件,除非在衍生的類別已覆寫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 None