Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/silverlight/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Silverlight Usercontrol clr命名空间_Silverlight_Xaml_User Controls - Fatal编程技术网

Silverlight Usercontrol clr命名空间

Silverlight Usercontrol clr命名空间,silverlight,xaml,user-controls,Silverlight,Xaml,User Controls,我正在构建一个silverlight MVVM应用程序(使用GalaSoft MVVM light模板)。该应用程序有一些用户控件。现在我遇到了一些看起来像是名称空间问题的问题。名称空间的定义方式如下: MyApp.Controls -> my user controls MyApp.View -> different pages of the app (which use the user controls) MyApp -> the namespace of the ma

我正在构建一个silverlight MVVM应用程序(使用GalaSoft MVVM light模板)。该应用程序有一些用户控件。现在我遇到了一些看起来像是名称空间问题的问题。名称空间的定义方式如下:

MyApp.Controls
-> my user controls 
MyApp.View
-> different pages of the app (which use the user controls)
MyApp
-> the namespace of the main page (root namespace)
只要我不给任何UserControls一个x:Name,这就可以了。一旦定义了x:Name,生成就会中断,并显示以下消息:

error CS0426: The type name 'Controls' does not exist in the type 'MyApp.MyApp'
真奇怪!我可以通过将名称空间MyApp.Controls更改为MyAppControls或通过操作生成的代码来解决此问题,以便直接引用MyApp.Controls.MyControl替换为使用MyApp.Controls,然后将控件与MyControl实例化(但是,一旦切换到desgin视图,这将再次被覆盖)


有人知道这种奇怪行为的原因吗?我本以为这是一个非常普遍的问题

我想我找到了原因:我还有一个名为MyApp的资源文件。这导致了类MyApp的生成,因此编译器在类MyApp和命名空间MyApp之间产生了混淆。我已将资源文件重命名为其他文件,现在项目将再次编译。

能否附上示例代码?抱歉,项目非常复杂。我试图简化它,但后来问题解决了。所以一定有什么我忽略了:-(。