ThemeableAttribute ThemeableAttribute ThemeableAttribute ThemeableAttribute Class

定義

定義中繼資料屬性,此屬性是 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
type ThemeableAttribute = class
    inherit Attribute
Public NotInheritable Class ThemeableAttribute
Inherits Attribute
繼承
ThemeableAttributeThemeableAttributeThemeableAttributeThemeableAttribute
屬性

範例

下列程式碼範例會示範如何將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至此函式會產生ThemeableAttributeNo欄位相等的實例)。(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) ]
        [IDReferenceProperty()]
        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 
        Get
            Return MyBase.DataSourceID
        End Get
        Set
            MyBase.DataSourceID = value
        End Set
    End Property
    
End Class 'SomeDataBoundControl 

備註

控制項開發人員使用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)屬性裝飾成員可確保成員不會有主題, 不論EnableTheming屬性的值為何。Decorating 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屬性設定為true, 控制項也不會受到主題的影響。For 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.

類別會維護所有支援主題之類型的靜態清單, 而且每當呼叫靜態方法IsObjectThemeableIsTypeThemeable時, 就會參考這份清單。 ThemeableAttributeThe 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(Boolean) ThemeableAttribute(Boolean) ThemeableAttribute(Boolean) ThemeableAttribute(Boolean)

初始化 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.

欄位

Default Default Default Default

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

No No No No

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

Yes Yes Yes Yes

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

屬性

Themeable Themeable Themeable Themeable

取得值,指出目前控制項或控制項成員是否受 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.

TypeId TypeId TypeId TypeId

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

(Inherited from Attribute)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

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

GetType() GetType() GetType() GetType()

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

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

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

IsObjectThemeable(Object) IsObjectThemeable(Object) IsObjectThemeable(Object) IsObjectThemeable(Object)

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

IsTypeThemeable(Type) IsTypeThemeable(Type) IsTypeThemeable(Type) IsTypeThemeable(Type)

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

Match(Object) Match(Object) Match(Object) Match(Object)

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

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

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

(Inherited from Object)

明確介面實作

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

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

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

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

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

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

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

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

(Inherited from Attribute)

適用於

另請參閱