WPF:XAML自定义命名空间 [英] WPF: XAML Custom Namespace

查看:356
本文介绍了WPF:XAML自定义命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,所以我在WPF中有一个Window.我在其中添加以下行:

xmlns:controls="clr-namespace:mCubed.Controls"

这可以编译并正常运行,但是Visual Studio设计器给了我这个错误:

无法加载文件或程序集'mCubed,版本= 1.0.0.0,区域性=中性,PublicKeyToken =空'或其依赖项之一.系统找不到指定的文件.

当我从Window删除此行时,它会编译并运行得很好,而Visual Studio设计器的工作就像一个吊饰!

我很困惑为什么一条线打断了设计师?如果我将以下行放在XAML文档的正文中,则会发生 REGARDLESS .

<controls:MyControl/>

我所有的.cs文件都在同一个VS项目中.我有一个mCubed命名空间,其中包含我巧妙命名的mCubedWindow类.我在mCubed.Controls命名空间中定义了所有控件类.不要告诉我这是一个汇编问题,我的所有文件都与VS项目相同!

解决方案

不是组装问题,只是设计者问题. VS WPF设计人员在2008年充其量是原始的-完全没用的恕我直言.我将其完全关闭,而改用XML编辑器.希望2010年情况会大为改善.

Okay so I have a Window in WPF. I add the following line inside of it:

xmlns:controls="clr-namespace:mCubed.Controls"

This compiles and runs just fine, but the Visual Studio designer gives me this error:

Could not load file or assembly 'mCubed, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

When I remove this line from the Window, it compiles and runs just fine and the Visual Studio designer works like a charm!

I'm confused as to why that one line breaks the designer? This occurs REGARDLESS if I have put the following line in the body of the XAML document.

<controls:MyControl/>

All my .cs files are in the same VS project. I have a mCubed namespace which contains my cleverly named mCubedWindow class. I have all my controls classes defined in the mCubed.Controls namespace. Do NOT tell me this is an assembly problem, ALL MY FILES ARE IN THE SAME VS PROJECT!

解决方案

Not an assembly problem, just a designer problem. The VS WPF designer in 2008 is primitive at best - completely useless IMHO. I turn it off completely and use the XML editor instead. Hopefully things will improve drastically in 2010.

这篇关于WPF:XAML自定义命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆