wpf 如何修复:此处不允许使用 XAML2009 语言构造?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14347181/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix: XAML2009 language construct is not allowed here?
提问by Michel Keijzers
In my App.xaml code I have the following code:
在我的 App.xaml 代码中,我有以下代码:
<Application x:Class="PcgTools.App"
...
<Application.Resources>
<ResourceDictionary>
...
<res:Strings x:FactoryMethod="res:StringResourceHelper.GetStringResources"
x:Key="LocStrings"/>
</ResourceDictionary>
</Application.Resources>
</Application>
I got from the VS2012 compiler an error before to use the FactoryMethod or Attribute construct. But now I get the error: Xaml2009 language construct is not allowed here.
在使用 FactoryMethod 或 Attribute 构造之前,我从 VS2012 编译器收到一个错误。但是现在我收到错误消息:此处不允许使用 Xaml2009 语言构造。
How to fix this?
如何解决这个问题?
回答by Duncan Matheson
XAML 2009 is unfortunately useless due to lack of compiler support (although VS recognises it for some stupid reason).
不幸的是,由于缺乏编译器支持,XAML 2009 毫无用处(尽管 VS 出于某些愚蠢的原因识别了它)。
请参阅: XAML 2009 上的 MSDN 文档
Basically no current compiler (WPF, SL, WinRT) actually supports it. As far as I know, the only thing which supports XAML 2009 is "loose xaml", where you have a stand-alone xaml file that is opened by a browser directly (which is basically useless).
基本上没有当前的编译器(WPF、SL、WinRT)实际支持它。据我所知,唯一支持 XAML 2009 的是“松散的 xaml”,在那里你有一个独立的 xaml 文件,由浏览器直接打开(这基本上是没用的)。
I don't know of any explanation from Microsoft outlining why on earth it isn't supported. :-(
我不知道微软有什么解释概述了为什么它不受支持。:-(
回答by Federico Berasategui
XAML 2009 is not allowed in compiled XAML (at least not in WPF 4.0), try to move your stuff that uses 2009 constructs to a separate Resource Dictionary file.
XAML 2009 不允许在已编译的 XAML 中(至少在 WPF 4.0 中不允许),请尝试将使用 2009 构造的内容移动到单独的资源字典文件中。

