ThemeableAttribute 类

定义

对 Web 服务器控件及其成员用于指示其呈现是否受主题和控件外观影响的元数据特性进行定义。 此类不能被继承。

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
属性

示例

下面的代码示例演示如何将 特性应用于 ThemeableAttribute 控件的成员。 在此示例中, ThemeableAttribute 应用于数据绑定控件并 false 传递给 ThemeableAttribute 构造函数,指示成员 DataSourceID 无法应用主题。 (传递给 false 构造函数会导致 ThemeableAttribute 实例等效于 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 属性来修饰控件类型及其成员,以指示哪些控件可以和不能受主题和控件外观的影响。 默认情况下,控件公开的所有属性都是可主题的。 但是,主题通常仅应用于风格属性;属性 Themeable(false) 应显式应用于所有非样式属性。 使用 Themeable(false) 属性修饰成员可确保成员不是主题成员,而不考虑 属性的值 EnableTheming 。 例如,如果 属性 ThemeableAttribute 应用于控件并设置为 false,则即使控件 EnableTheming 的 属性设置为 true,该控件也不会受到主题的影响。

ThemeableAttribute 维护支持主题的所有类型的静态列表,每当调用静态方法和 IsObjectThemeableIsTypeThemeable 时,都会查询此列表。

构造函数

ThemeableAttribute(Boolean)

使用指定的布尔值确定特性是否表示受主题和控件外观影响的类型或成员,初始化 ThemeableAttribute 类的新实例。

字段

Default

获取一个 ThemeableAttribute 实例,该实例表示应用程序定义的特性默认值。

No

获取一个 ThemeableAttribute 实例,该实例用于修饰不受主题和控件外观影响的类型或成员。

Yes

获取一个 ThemeableAttribute 实例,该实例用于修饰受主题和控件外观影响的类型或成员。

属性

Themeable

获取一个值,该值指示当前控件或控件的成员是否受 Web 应用程序中定义的主题和控件外观影响。

TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。

(继承自 Attribute)

方法

Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。

GetHashCode()

用作 ThemeableAttribute 类型的哈希函数。

GetType()

获取当前实例的 Type

(继承自 Object)
IsDefaultAttribute()

获取一个值,该值指示当前实例是否等效于 Default 类的 ThemeableAttribute 实例。

IsObjectThemeable(Object)

返回一个值,该值指示传递给该方法的对象是否支持主题。

IsTypeThemeable(Type)

返回一个值,该值指示传递给该方法的 Type 是否支持主题。

Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。

(继承自 Attribute)
MemberwiseClone()

创建当前 Object 的浅表副本。

(继承自 Object)
ToString()

返回表示当前对象的字符串。

(继承自 Object)

显式接口实现

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

将一组名称映射为对应的一组调度标识符。

(继承自 Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。

(继承自 Attribute)
_Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。

(继承自 Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。

(继承自 Attribute)

适用于

另请参阅