FrameworkElement.OverridesDefaultStyle 屬性


取得或設定此元素的樣式屬性是否來自佈景主題樣式的值。Gets or sets a value that indicates whether this element incorporates style properties from theme styles.

 property bool OverridesDefaultStyle { bool get(); void set(bool value); };
public bool OverridesDefaultStyle { get; set; }
member this.OverridesDefaultStyle : bool with get, set
Public Property OverridesDefaultStyle As Boolean



如果這個項目不會使用佈景主題樣式,所有從樣式產生的屬性都來自本機應用程式樣式,且佈景主題樣式屬性不會套用,則為 truetrue if this element does not use theme style properties; all style-originating properties come from local application styles, and theme style properties do not apply. 如果應用程式樣式先套用,然後針對不是在應用程式樣式中具體設定的屬性套用佈景主題樣式則為 falsefalse if application styles apply first, and then theme styles apply for properties that were not specifically set in application styles. 預設為 falseThe default is false.


這個屬性的最常見用法是提供主題樣式之樣式 setter 內的間接使用方式。The most common usage of this property is an indirect usage within the setter of a style that is supplying a themed style.


如果您在 OverridesDefaultStyle 控制項上將設定為 true ,則會隱藏主題樣式所提供的預設控制項範本。If you set OverridesDefaultStyle to true on a control, you will be suppressing the default control template supplied by the theme styles. 該控制項範本通常包含內容展示者和其他提供 UIUI 控制項基本功能和視覺效果的複合元素。That control template typically includes the content presenter and other composited elements that provide basic UIUI functionality and visualization for the control. 如果您希望控制項繼續支援與預設主題樣式相同的功能,您必須提供具有複製相同結構之控制項範本的替代樣式。If you want the control to continue to support the same features as the default theme styles, you must supply an alternate style with a control template that replicates the same structure. 如需詳細資訊,請參閱控制項撰寫概觀For more information, see Control Authoring Overview.

相依性屬性資訊Dependency Property Information

識別碼欄位Identifier field OverridesDefaultStyleProperty
中繼資料屬性設定為 trueMetadata properties set to true AffectsMeasure