NameScopePropertyAttribute 类

定义

指定提供 XAML 名称范围值的关联类的属性。Specifies a property of the associated class that provides the XAML namescope value.

public ref class NameScopePropertyAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Class, AllowMultiple=false, Inherited=true)]
public sealed class NameScopePropertyAttribute : Attribute
type NameScopePropertyAttribute = class
    inherit Attribute
Public NotInheritable Class NameScopePropertyAttribute
Inherits Attribute
继承
NameScopePropertyAttribute
属性

注解

在使用 XAML 的典型对象模型/应用程序模型组合中, 用作 XAML 名称范围的类是通常用作根元素或支持页比喻的类。In a typical object model / application model combination where XAML is used, the classes that are used as a XAML namescope are the classes that are generally used as root elements, or that support a page metaphor. 在框架的编程INameScope模型和应用程序模型的上下文中, 通常通过典型的 xaml 处理行为, 使用这些类来实现和创建 xaml 名称范围。These classes generally implement INameScope and the XAML namescope is created corresponding to the root by typical XAML processing behavior in context of a framework's programming model and application model.

如果NameScopePropertyAttribute使用, 则 XAML 名称范围属性值应为实现INameScope并保存实际 XAML 名称范围及其行为的对象。If NameScopePropertyAttribute is used, the XAML namescope property value is expected to be an object that implements INameScope and holds the actual XAML namescope and its behavior.

此属性有两种形式: 仅属性名称或类型和属性。There are two forms for this attribute: property name only, or type and property. 后一种形式应该只用于包含 XAML 名称作用域的属性是可附加成员。The latter form should be used only for cases where the property that holds the XAML name scope is an attachable member. 附加成员技术的优势在于, 服务类可以实现可支持多种不同对象类型的 XAML 名称范围概念。The attached member technique has the advantage that service classes can implement a XAML namescope concept that can support several different object types. 然后, 这些对象类型不需要在类继承中显式关联。Those object types then do not need to be explicitly related in class inheritance.

在 .NET Framework 的以前版本中, 此类存在于 WPF 特定的程序集 WindowsBase 中。In previous versions of the .NET Framework, this class existed in the WPF-specific assembly WindowsBase. .NET Framework 4.NET Framework 4NameScopePropertyAttribute , 为 system.exception 程序集。In .NET Framework 4.NET Framework 4, NameScopePropertyAttribute is in the System.Xaml assembly. 有关详细信息,请参阅 Types Migrated from WPF to System.XamlFor more information, see Types Migrated from WPF to System.Xaml.

WPF 用法说明WPF Usage Notes

在 WPF 中, 此特性仅应用于单个类型DependencyObjectIn WPF, this attribute is applied to only a single type, DependencyObject. 在这种情况下, 属性化属性为NameScope服务类NameScope.NameScope及其附加属性。In this case the attributed property is the service class NameScope and its NameScope.NameScope attached property.

构造函数

NameScopePropertyAttribute(String)

用指定的名称初始化 NameScopePropertyAttribute 类的新实例。Initializes a new instance of the NameScopePropertyAttribute class with the specified name.

NameScopePropertyAttribute(String, Type)

用指定的名称和类型初始化 NameScopePropertyAttribute 类的新实例。Initializes a new instance of the NameScopePropertyAttribute class with the specified name and type.

属性

Name

获取提供 XAML 名称范围的属性的名称。Gets the name of the property that provides the XAML namescope.

Type

获取提供 XAML 命名空间支持的所附加属性的所有者类型。Gets the owner type of the attached property that provides the XAML namescope support.

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.

(继承自 Attribute)
GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(继承自 Attribute)
GetType()

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

(继承自 Object)
IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(继承自 Attribute)
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)

适用于

另请参阅