#85 – Two Main Namespaces Used in Every WPF XAML File

You’ll find the same two namespaces listed at the top of every .xaml file in a WPF project:

 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

These namespaces correspond to two XAML vocabularies that define elements allowed in a WPF-based XAML file.

Although a URI is used to specify each namespace, they do not correspond to an actual web site.  The URI format is used to help ensure uniqueness across all organizations.

More information on these two namespaces :

Advertisement

#72 – XAML Namespaces

In XAML, a namespace is a collection of names, identified by a URI reference, which are used in XAML documents as element types and attribute names.  (See W3C definition of namespace).

In addition to being just a collection of allowed element and attribute names, a XAML namespace maps this set of names to the corresponding .NET classes in one or more .NET namespaces.

A namespace is uniquely identified by a URI that is typically included as an attribute in the root element in a XAML file, using the xmlns attribute.  The root element must include at least one xmlns attribute.  This attribute defines the namespace that contains definitions of elements and attributes in the XAML file.

The default namespace used in WPF is http://schemas.microsoft.com/winfx/2006/xaml/presentation.

<Window x:Class="WpfApplication1.MainWindow"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             Title="MainWindow" Height="350" Width="525">

See also – XAML Namespaces and Namespace Mapping for WPF XAML