的xmlns =http://schemas.microsoft.com/winfx/2006/xaml/$p$psentation
这是怎么URL映射到.NET命名空间?你能举一个例子如何做同样的事情自定义的.NET类/命名空间?它是一个必须的命名空间本身呢?
中定义的属性或者是一个物质或使用C#别名如:
using别名= FullNamespace
解决方案
映射使用的 XmlnsDefinition
属性。例如:
[总成:XmlnsDefinition(http://schemas.microsoft.com/winfx/2006/xaml/$p$psentation,System.Windows.Data)
[总成:XmlnsDefinition(http://schemas.microsoft.com/winfx/2006/xaml/$p$psentation,System.Windows)
[总成:XmlnsDefinition(http://schemas.microsoft.com/winfx/2006/xaml/$p$psentation,System.Windows.Controls.Primitives)
[总成:XmlnsDefinition(http://schemas.microsoft.com/winfx/2006/xaml/$p$psentation,System.Windows.Media.Animation)
[总成:XmlnsDefinition(http://schemas.microsoft.com/winfx/2006/xaml/$p$psentation,System.Windows.Input)
(由presentationFramework.dll与反射提取code)
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
解决方案
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)