tags:

views:

22

answers:

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

How is this url mapped to .NET namespaces? Can you give an example how to do the same thing for custom .NET classes/namespaces? Is it an attribute that has to be defined on the namespace itself?

Or is it a matter or using C# aliases as in?:

using alias = FullNamespace
+1  A: 

The mapping is done using the XmlnsDefinition attribute. For instance :

[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Data")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Controls.Primitives")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Media.Animation")]
[assembly: XmlnsDefinition("http://schemas.microsoft.com/winfx/2006/xaml/presentation", "System.Windows.Input")]

(code from PresentationFramework.dll extracted with Reflector)

Thomas Levesque
Thanks, so I can use the same url too, right?
Joan Venge
Yes, but I wouldn't recommend it, because it could cause conflicts between your classes and those from the standard WPF namespaces
Thomas Levesque
Thanks, sounds reasonable.
Joan Venge