INameScope.RegisterName(String, Object) 方法

定义

将提供的名称注册到当前的 XAML 名称范围中。Registers the provided name into the current XAML namescope.

public:
 void RegisterName(System::String ^ name, System::Object ^ scopedElement);
public void RegisterName (string name, object scopedElement);
abstract member RegisterName : string * obj -> unit
Public Sub RegisterName (name As String, scopedElement As Object)

参数

name
String

要注册的名称。The name to register.

scopedElement
Object

提供的 name 所引用的特定元素。The specific element that the provided name refers to.

注解

XAML 名称范围中不允许有重复的名称。Duplicate names in a XAML namescope are not permitted.

实施者说明

不允许注册重复的名称。Do not permit duplicate names to be registered. 如果输入 name 已分配到 XAML 名称范围的内部集合表示形式中的现有元素(即使它与 scopedElement相同),则将引发异常。If the input name is already assigned to an existing element in the internal collection representation of the XAML namescope (even if it is the same as scopedElement), throw an exception.

如果提供的名称不符合XamlName 语法,还应考虑引发异常。Also consider throwing an exception if the provided name does not conform to XamlName Grammar.

适用于

另请参阅