在 WPF 中使用 Blend 4 进行重构视觉工作室2010

发布于 2024-10-08 13:43:01 字数 401 浏览 0 评论 0原文

我一直在 Visual Studio 2010 (Express) 和 Blend 4 中进行重构,我发现它有点挑剔,但我想确保我做得正确,所以......问题:

1 )似乎重构(重命名 UserControl,包括 xaml 和 cs 文件名)的最佳方法是从 Visual Studio 中的 cs 文件中执行此操作。这是正确的吗?

1a) 在 Blend 中工作时重命名控件的最简单方法是什么? (我经常这样做。)

2)在我习惯的 Java 工具中,重命名总是意味着重构(不仅自动更改类名,还自动更改文件名)。但在Blend/VS中,两者似乎有区别?

3)是否有重命名控件而不是重构的用途,或者重命名只是针对资源而不是xaml/cs文件之类的东西?

4)为什么重构类名不会更改文件名以自动匹配?

I've been playing around with refactoring in Visual Studio 2010 (Express) and Blend 4, and I've found that it's a little picky, but I want to make sure I'm doing it right, so...questions:

1) It seems like the best way to refactor (rename say a UserControl, including the xaml and cs filenames) is to do it from Visual Studio within the cs file. Is that correct?

1a) What's the easiest way to rename a control when you're working in Blend? (I do this often.)

2) In the Java tools I'm used to, renaming always implies refactoring (automatically changing not only class names but file names also). But in Blend/VS, it seems there's a distinction between the two?

3) Is there a use for renaming a control rather than refactoring, or is rename just for things like resources rather than xaml/cs files?

4) Why doesn't refactoring a class name change the file name to match automatically?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一页 2024-10-15 13:43:01

1,2) 在 Visual Studio 中,如果您从解决方案资源管理器更改名称,系统会询问您是否也想更改类名称。这将自动重构您的代码。从代码中更改名称(快捷键 F2)只会重构您的代码,而不会更改相应的文件名。

3)重命名控件(也是类)只是重构。

4) 首先,一个文件可以包含多个类。

--编辑--

嗯...似乎从 VS 2010 Professional 中的解决方案资源管理器重命名 WPF 控件也不会提示重构代码或标记。不过,这似乎只是 XAML 文件的问题;即使在 Express 版本中,解决方案资源管理器中的类的重命名重构也应该有效。

顺便说一下,我在 MSDN。

1,2) In Visual Studio, if you change the name from the Solution Explorer, you will be asked if you also want to change the class name. This will automatically refactor your code. Changing the name from the code (shortcut F2) will only refactor your code and not change the corresponding filenames.

3) Renaming a control (which is also a class) is just refactoring.

4) For one, a file can contain multiple classes.

--EDIT--

Hmm... It seems that renaming a WPF control from the Solution Explorer in VS 2010 Professional also doesn't prompt for refactoring your code, nor markup. This seems to be an issue with XAML files only, though; rename-refactoring of classes from the solution explorer shoudld work even with express editions.

By the way, I found a nice article on rename-refactoring with VS on MSDN.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文