默认的xml命名空间如何在XAML中工作?

时间:2010-03-25 16:53:06

标签: c# .net wpf xaml

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

这个url如何映射到.NET命名空间?您能举例说明如何为自定义.NET类/命名空间做同样的事情吗?它是一个必须在命名空间本身上定义的属性吗?

或是使用C#别名还是在?:

using alias = FullNamespace

1 个答案:

答案 0 :(得分:3)

使用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代码)