Sends for the fellow dear visitors:welcome to dongpad!


 Welcome to DongPad!

 msn


How to make XmlnsDefinition work on the local assembly?

track @ http://stackoverflow.com/questions/2760504/how-to-make-xmlnsdefinition-work-on-the-local-assembly

Q:

I've started using the XmlnsDefinition attribute to tie together some CLR namespaces into a single xmlns for convenience in XAML.

Unfortunately, it seems that this only works when using foreign assemblies. If I have a XAML file in the same assembly as the types that are in the namespace I'm referencing from XmlnsDefinition, then the compiler gives an error about the type not existing in the xmlns I am defining.

Moving the type to a foreign assembly fixes the problem.

Is there a way to use XmlnsDefinition on an assembly and have it be used from within that assembly via XAML?

A:

Unfortunately, no. The XAML file must be parsed before the assembly is built in order to generate the code implied by the XAML to be included in the assembly. The XAML compiler produces code behind files (the files ending in, for example, .g.cs) and these file then become part of the assembly the XAML file is contained in. Since the assembly hasn't been built yet, the XAML compiler cannot load it to determine XmlnsDeclaration attributes have been specified.



评论: 0 | 引用: 0 | 查看次数: 803 | 返回顶部
发表评论
昵 称:    
验证码:   
 
内 容:
选 项:  
 
虽然发表评论不用注册,但是为了保护您的发言权,建议您注册帐号.
字数限制 500 字 | UBB代码 开启 | [img]标签 开启