FrameworkElement.FocusVisualStyle FrameworkElement.FocusVisualStyle FrameworkElement.FocusVisualStyle FrameworkElement.FocusVisualStyle Property

定義

取得或設定屬性,這個屬性可自訂外觀、效果或其他樣式特性,以在這個項目捕捉到鍵盤焦點時套用至項目。Gets or sets a property that enables customization of appearance, effects, or other style characteristics that will apply to this element when it captures keyboard focus.

public:
 property System::Windows::Style ^ FocusVisualStyle { System::Windows::Style ^ get(); void set(System::Windows::Style ^ value); };
public System.Windows.Style FocusVisualStyle { get; set; }
member this.FocusVisualStyle : System.Windows.Style with get, set
Public Property FocusVisualStyle As Style

屬性值

要在取得焦點時套用的樣式。The desired style to apply on focus. 相依性屬性中所宣告的預設值是空的靜態 StyleThe default value as declared in the dependency property is an empty static Style. 不過,執行階段的有效值通常是 (但不一定總是) 佈景主題支援為控制項所提供的樣式。However, the effective value at run time is often (but not always) a style as supplied by theme support for controls.

備註

這個屬性會影響視覺外觀,但不會報告AffectsRender中繼資料中。This property affects visual appearance but does not report AffectsRender in metadata. 這是因為視覺外觀變更事件驅動,隨時可能不適用且因此通常不應該報告中繼資料中的任何視覺效果] 或 [版面配置資訊。This is because the visual appearance change is event-driven and may not apply at all times, and therefore should not generally report any visual or layout information in metadata.

就概念而言,套用至控制項的焦點視覺行為應該保持一致控制項。Conceptually, the visual behavior of focus applied to a control should be coherent from control to control. 若要只變更焦點視覺化樣式,當您在撰寫整個佈景主題,是最合理的方式,來強制執行一致性。The most sensible way to enforce coherence is to only change the focus visual style if you are composing an entire theme. 設定這個屬性上個別控制項的樣式,而不是屬於佈景主題不是預定的使用方式,此屬性,因為它可能會導致令人困惑的使用者體驗,關於鍵盤焦點。Setting this property on individual control styles and not as part of a theme is not the intended usage of this property, because it may lead to a confusing user experience regarding keyboard focus. 如果您打算是刻意不一致整個佈景主題的控制項特定行為,更好的方法是使用觸發程序在樣式中個別輸入的狀態屬性,這類IsFocusedIsKeyboardFocusWithin,以及若要這樣做並不會的方式以視覺化方式會影響任何現有的焦點視覺化樣式。If you are intending control-specific behavior that is deliberately not coherent across a theme, a much better approach is to use triggers in styles for individual input state properties, such as IsFocused or IsKeyboardFocusWithin, and to do so in a way that does not visually interfere with any existing focus visual style. 如需有關的設計用意FocusVisualStyle及替代專注屬性,請參閱 < 設定在控制項和 FocusVisualStyle 焦點的樣式For more information on the design intention of FocusVisualStyle and alternative focus properties, see Styling for Focus in Controls, and FocusVisualStyle.

XAML Attribute UsageXAML Attribute Usage

<object FocusVisualStyle="{resourceExtension styleResourceKey}"/>  

XAML 屬性項目用法XAML Property Element Usage

XAML 值XAML Values

resourceExtensionresourceExtension
下列其中之一:、 或。One of the following: , or . 請參閱XAML 資源See XAML Resources.

styleResourceKeystyleResourceKey
識別所要求的樣式索引鍵。The key that identifies the style being requested. 索引鍵參考中的現有資源ResourceDictionaryThe key refers to an existing resource in a ResourceDictionary.

注意

屬性元素語法是技術上可行,但不是建議使用。Property element syntax is technically possible, but not recommended. 請參閱內嵌樣式和範本See Inline Styles and Templates. 使用繫結參考TemplateBindingBinding也是可行的但不常見。A binding reference using TemplateBinding or Binding is also possible, but uncommon.

相依性屬性資訊Dependency Property Information

識別項欄位Identifier field FocusVisualStyleProperty
若要設定的中繼資料屬性 trueMetadata properties set to true None

適用於

另請參閱