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

4
在Visual Studio 2008/2010中,可以在解决方案资源管理器中将一系列简单的.cs代码文件放置在另一个.cs文件下面。这种行为类似于向解决方案添加WPF UserControl时看到的文件排列方式,其中一个单独的.cs文件可以在.xaml文件下折叠/展开。
如何使解决方案以这种方式排列文件?我已经在一些显而易见的地方查找过,例如文件属性窗格、解决方案和.csproj属性页面。

2个回答

5

我不确定是否可以通过Visual Studio界面来完成此操作。

您可以通过手动编辑.csproj文件来实现。关键在于向要出现在另一个元素下面的元素添加<DependentUpon>XML标签。例如:

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

使用VSCommands http://visualstudiogallery.msdn.microsoft.com/en-us/d491911d-97f3-4cf6-87b0-6a2882120acf - user97562

5

您需要编辑 .csproj 文件并添加以下内容:

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

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接