【发布时间】:2010-03-25 16:53:05
【问题描述】:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
这个 url 如何映射到 .NET 命名空间?您能否举例说明如何为自定义 .NET 类/命名空间做同样的事情?它是必须在命名空间本身上定义的属性吗?
或者是问题还是使用 C# 别名?:
using alias = FullNamespace
【问题讨论】:
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
这个 url 如何映射到 .NET 命名空间?您能否举例说明如何为自定义 .NET 类/命名空间做同样的事情?它是必须在命名空间本身上定义的属性吗?
或者是问题还是使用 C# 别名?:
using alias = FullNamespace
【问题讨论】:
映射是使用XmlnsDefinition 属性完成的。例如:
[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")]
(使用 Reflector 提取的 PresentationFramework.dll 中的代码)
【讨论】: