#73 – Multiple Namespaces Using Prefixes

You can use multiple namespaces in a XAML file, allowing you to use names from multiple namespaces in the same file.

When you use more than one namespace, you need to associate all but one of the namespaces with a prefix, which you use to qualify names belonging to the prefixed namespaces.  You can include one namespace (the default namespace) that does not include a prefix.

In WPF, two namespaces are typically used:

<Application x:Class="WpfApplication1.App"

In this example, the second namespace uses the “x” prefix, declaring the prefix as part of the xmlns attribute.  All names qualified with the “x” prefix, e.g. x:Class, belong to this namespace.

The first namespace in the example does not include a prefix.  All names in the XAML file not qualified with a prefix are assumed to belong to this namespace–e.g. StartupUri.