In Silverlight, a XAML namescope stores relationships between the XAML-defined names of objects and their instance equivalents. This is similar to the wider meaning of the term "namescope" in other programming languages and technologies. XAML namescopes are created while parsing a XAML source and creating an object representation. The names in a XAML namescope are then used by code-behind operations at run time to access the objects that were created by parsing the XAML.

How XAML Namescopes Are Defined

A name is specified in XAML by setting the value for one of two nearly equivalent attributes, Name or x:Name. (For details on the distinction between Name and x:Name, see Remarks in Name.) If you attempt to define the same name twice within any XAML namescope, an exception is thrown during parsing.

In general, attributes in XAML can be specified only on object elements. Property elements (used to provide values for certain Silverlight properties in XAML) cannot have a Name or x:Name.