ThemeableAttribute 類別


定義中繼資料屬性,此屬性是 Web 伺服器控制項及其成員用來指示,其呈現是否受主題和控制面板影響。Defines the metadata attribute that Web server controls and their members use to indicate whether their rendering can be affected by themes and control skins. 此類別無法獲得繼承。This class cannot be inherited.

public ref class ThemeableAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Property)]
public sealed class ThemeableAttribute : Attribute
[<System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Property)>]
type ThemeableAttribute = class
    inherit Attribute
Public NotInheritable Class ThemeableAttribute
Inherits Attribute


下列程式碼範例會示範如何將屬性套用 ThemeableAttribute 至控制項的成員。The following code example demonstrates how you can apply the ThemeableAttribute attribute to a member of a control. 在此範例中, ThemeableAttribute 會套用至資料繫結控制項,並 false 傳遞至函式 ThemeableAttribute ,表示該 DataSourceID 成員無法套用主題。In this example, ThemeableAttribute is applied to a data-bound control and false is passed to the ThemeableAttribute constructor, indicating that the DataSourceID member cannot have themes applied. 傳遞至函式 (false ThemeableAttribute 會產生相當於該欄位的實例 No ) (Passing false to the constructor results in a ThemeableAttribute instance that is equivalent to the No field.)

namespace Samples.AspNet.CS.Controls {
    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;

    public class SomeDataBoundControl : DataBoundControl
        // Implementation of a custom data source control.
        [Themeable(false) ]
        public override string DataSourceID {
            get {
                return base.DataSourceID;
            set {
                base.DataSourceID = value;
Imports System.Web.UI
Imports System.Web.UI.WebControls

Public Class SomeDataBoundControl
    Inherits DataBoundControl

    ' Implementation of a custom data source control.
    <Themeable(False)> _
    <IDReferenceProperty()>  _
    Public Overrides Property DataSourceID() As String 
            Return MyBase.DataSourceID
        End Get
            MyBase.DataSourceID = value
        End Set
    End Property
End Class


控制項開發人員使用 ThemeableAttribute 屬性裝飾控制項類型及其成員,以表示哪些控制項和控制項的外觀可能會受到影響。Control developers use the ThemeableAttribute attribute to decorate control types and their members, to signal which ones can and cannot be affected by themes and control skins. 依預設,控制項公開的所有屬性都是 themeable。By default, all properties exposed by a control are themeable. 不過,主題通常僅適用于樣式屬性; Themeable(false) 屬性應該明確地套用至所有非樣式屬性。However, themes are typically applied only to stylistic properties; the Themeable(false) attribute should be applied explicitly to all non-stylistic properties. 以屬性裝飾成員 Themeable(false) 可確保不論屬性的值為何,都不會有主題的成員 EnableThemingDecorating a member with the Themeable(false) attribute ensures that the member is not themed, regardless of the value of the EnableTheming property. 例如,如果將 ThemeableAttribute 屬性套用至控制項並設定為 false ,即使控制項的屬性設定為,控制項也不會受到主題的影響 EnableTheming trueFor example, if the ThemeableAttribute attribute is applied to a control and set to false, the control is not affected by themes even when its EnableTheming property is set to true.

ThemeableAttribute類別會維護所有支援主題的型別的靜態清單,而且每當呼叫靜態方法和時,就會參考此清單 IsObjectThemeable IsTypeThemeableThe ThemeableAttribute class maintains a static list of all types that support themes, and this list is consulted whenever the static methods IsObjectThemeable and IsTypeThemeable are called.



初始化 ThemeableAttribute 類別的新執行個體,並使用指定的布林值判斷屬性表示的型別或成員是否會受主題和控制面板影響。Initializes a new instance of the ThemeableAttribute class, using the specified Boolean value to determine whether the attribute represents a type or member that is affected by themes and control skins.



取得 ThemeableAttribute 執行個體,表示應用程式定義的屬性預設值。Gets a ThemeableAttribute instance that represents the application-defined default value of the attribute.


取得 ThemeableAttribute 執行個體,用來裝飾不受主題和控制面板影響的型別或成員。Gets a ThemeableAttribute instance used to decorate a type or member that is not affected by themes and control skins.


取得 ThemeableAttribute 執行個體,用來裝飾受主題和控制面板影響的型別或成員。Gets a ThemeableAttribute instance used to decorate a type or member that is affected by themes and control skins.



取得值,指出目前控制項或控制項成員是否受 Web 應用程式定義的主題和控制面板影響。Gets a value indicating whether the current control or member of a control can be affected by themes and control skins defined for the Web application.


在衍生類別中實作時,取得這個 Attribute 的唯一識別碼。When implemented in a derived class, gets a unique identifier for this Attribute.

(繼承來源 Attribute)



傳回值,這個值指出此執行個體是否與指定的物件相等。Returns a value that indicates whether this instance is equal to a specified object.


做為 ThemeableAttribute 型別的雜湊函式。Serves as a hash function for the ThemeableAttribute type.


取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)

取得值,指出目前的執行個體是否等於 Default 類別的 ThemeableAttribute 執行個體。Gets a value indicating whether the current instance is equivalent to a Default instance of the ThemeableAttribute class.


傳回數值,指出傳遞至方法的物件是否支援主題。Returns a value indicating whether the object passed to the method supports themes.


傳回數值,指出傳遞至方法的 Type 是否支援主題。Returns a value indicating whether the Type passed to the method supports themes.


在衍生類別中覆寫時,會傳回值,表示這個執行個體是否等於指定物件。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(繼承來源 Attribute)

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)


_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

將一組名稱對應至一組對應的分派識別項 (Dispatch Identifier)。Maps a set of names to a corresponding set of dispatch identifiers.

(繼承來源 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

擷取物件的類型資訊,可以用來取得介面的類型資訊。Retrieves the type information for an object, which can be used to get the type information for an interface.

(繼承來源 Attribute)

擷取物件提供的類型資訊介面數目 (0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(繼承來源 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供物件所公開的屬性和方法的存取權。Provides access to properties and methods exposed by an object.

(繼承來源 Attribute)