如何在 Visual Studio 解决方案资源管理器中使 (.cs) 代码文件在另一个代码文件下展开/折叠?

发布于 2024-09-17 18:55:24 字数 218 浏览 2 评论 0原文

在 Visual Studio 2008/2010 中,可以将一系列简单的 .cs 代码文件放置在解决方案资源管理器中的另一个 .cs 文件下。此行为类似于将 WPF UserControl 添加到解决方案时看到的文件排列方式,其中单个 .cs 文件可以在 .xaml 文件下折叠/展开。

如何使解决方案以这种方式排列文件?我已经查看了一些明显的位置,例如文件属性窗格、解决方案和 .csproj 属性页。

In Visual Studio 2008/2010 it's possible to place a series of simple .cs code files underneath another .cs file in solution explorer. This behavior is similar to how you see files arranged when adding a WPF UserControl to the solution, where instead a single .cs file can collapse/expand underneath the .xaml file.

How do you make the solution arrange files this way? I've already looked in some of the obvious places, like the file properties pane, the solution and .csproj property pages.

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

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

发布评论

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

评论(2

凉风有信 2024-09-24 18:55:24

我不确定是否有办法通过 Visual Studio UI 来执行此操作。

您可以通过手动编辑 .csproj 文件来完成此操作。诀窍是将 XML 标记添加到要显示在另一个元素下的元素。例如

<Compile Include="Settings.Designer.cs">
  <AutoGen>True</AutoGen>
  <DependentUpon>Settings.settings</DependentUpon>
  <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>

I'm not sure there is a way to do this through the Visual Studio UI.

You can do it by manually editing the .csproj file. The trick is to add the <DependentUpon> XML tag to the element you want to appear under another. For example

<Compile Include="Settings.Designer.cs">
  <AutoGen>True</AutoGen>
  <DependentUpon>Settings.settings</DependentUpon>
  <DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
旧竹 2024-09-24 18:55:24

您必须编辑 .csproj 文件并添加以下内容:

<Compile Include="Form1.Designer.cs">
  <DependentUpon>Form1.cs</DependentUpon>
</Compile>

或者在 Visual Studio 2010 中安装像 VSCommands 这样的插件。

You have to edit the .csproj file and add this:

<Compile Include="Form1.Designer.cs">
  <DependentUpon>Form1.cs</DependentUpon>
</Compile>

Or install a plugin like VSCommands in Visual Studio 2010.

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