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

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

问题描述

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

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

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

这编译并运行得很好,但是 Visual Studio 设计器给了我这个错误:

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

无法加载文件或程序集 'mCubed, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' 或其依赖项之一.系统找不到指定的文件.

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.

当我从窗口中删除这一行时,它编译并运行得很好,Visual Studio 设计器就像一个魅力!

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

我很困惑为什么那一行会破坏设计器?如果我将以下行放入 XAML 文档的正文中,无论都会发生这种情况.

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/>

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

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!

推荐答案

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

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天全站免登陆