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
type ThemeableAttribute = class
    inherit Attribute
Public NotInheritable Class ThemeableAttribute
Inherits Attribute
继承
ThemeableAttribute
属性

示例

下面的代码示例演示如何将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) ]
        [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

注解

控件开发人员使用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 类的新实例。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

获取一个 ThemeableAttribute 实例,该实例表示应用程序定义的特性默认值。Gets a ThemeableAttribute instance that represents the application-defined default value of the attribute.

No

获取一个 ThemeableAttribute 实例,该实例用于修饰不受主题和控件外观影响的类型或成员。Gets a ThemeableAttribute instance used to decorate a type or member that is not affected by themes and control skins.

Yes

获取一个 ThemeableAttribute 实例,该实例用于修饰受主题和控件外观影响的类型或成员。Gets a ThemeableAttribute instance used to decorate a type or member that is affected by themes and control skins.

属性

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

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(继承自 Attribute)

方法

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

GetHashCode()

用作 ThemeableAttribute 类型的哈希函数。Serves as a hash function for the ThemeableAttribute type.

GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
IsDefaultAttribute()

获取一个值,该值指示当前实例是否等效于 Default 类的 ThemeableAttribute 实例。Gets a value indicating whether the current instance is equivalent to a Default instance of the ThemeableAttribute class.

IsObjectThemeable(Object)

返回一个值,该值指示传递给该方法的对象是否支持主题。Returns a value indicating whether the object passed to the method supports themes.

IsTypeThemeable(Type)

返回一个值,该值指示传递给该方法的 Type 是否支持主题。Returns a value indicating whether the Type passed to the method supports themes.

Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

显式界面实现

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

将一组名称映射为对应的一组调度标识符。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)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(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)

适用于

另请参阅