XAML and XAML Namespaces
XAML is a declarative XML-based language that is used as a user interface markup language in Windows Presentation Foundation (WPF) and the .NET Framework 3.0. With XAML you can create a graphically rich customized user interface, perform data binding, and much more. For more information on XAML and the .NET Framework 3.0, please see http://www.microsoft.com.
XAML Namespaces
Namespaces organize the objects defined in an assembly. Assemblies can contain multiple namespaces, which can in turn contain other namespaces. Namespaces prevent ambiguity and simplify references when using large groups of objects such as class libraries.
When you create a Microsoft Expression Blend project, a XAML file is created for you and some initial namespaces are specified:
Namespace |
Description |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
This is the default Windows Presentation Foundation namespace. |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
This is a XAML namespace that is mapped to the x: prefix. The x: prefix provides a quick, easy way to reference the namespace, which defines many commonly-used features necessary for WPF applications. |
When you add a C1DateTimePicker or a C1TimeEditor control to the window in Microsoft Expression Blend or Visual Studio, Blend or Visual Studio automatically creates an XML namespace for the control. The namespace looks like the following:
xmlns:my="clr-namespace:C1.WPF.DateTimeEditors;assembly=C1.WPF.DateTimeEditors"
The namespace value is my and the namespace is C1.WPF.DateTimeEditors.
You can also choose to create your own custom name for the namespace. For example:
xmlns:MyMTB=http://schemas.componentone.com/wpf/C1DateTimeEditors
You can now use your custom namespace when assigning properties, methods, and events. For example, use the following XAML to add a border around the panel:
<MyMTB:C1DateTimeEditors Name="c1DateTimeEditors1" BorderThickness="10,10,10,10">
|