2
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 Answer 1

4

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)

Sign up to request clarification or add additional context in comments.

1 Comment

Yes, but I wouldn't recommend it, because it could cause conflicts between your classes and those from the standard WPF namespaces

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.