2010-03-25 76 views
2
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 

这个url如何映射到.NET命名空间?你能举一个例子来说明如何为自定义.NET类/名称空间做同样的事情吗?它是一个必须在名称空间本身上定义的属性吗?默认的xml名称空间在XAML中如何工作?

或者是它的事,或者使用C#别名,如?:

using alias = FullNamespace 

回答

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")] 

+1

谢谢(从PresentationFramework.dll代码反射中提取),这样我就可以使用相同的URL过,对吧? – 2010-03-25 17:01:22

+1

是的,但我不会推荐它,因为它可能会导致您的类和标准WPF名称空间之间的冲突 – 2010-03-25 17:06:41

+0

谢谢,听起来很合理。 – 2010-03-25 17:09:50

相关问题