#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.


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: