在 Visual Studio 中分层显示一个文件在另一个文件下

Display a file hierarchically under another file in Visual Studio

在Visual Studio中,我想显示某些文件之间的层次关系。

典型的 ASP.NET WebForms 应用程序提供了我想要的示例。 假设我有一个名为 Page.aspx 的文件。名为 Page.aspx.csPage.aspx.designer.cs 的文件通常会在解决方案资源管理器中分层显示在 Page.aspx 下方。

如果您希望文件 A 在解决方案资源管理器中分层显示在文件 B 下,请执行以下操作:

打开您的项目文件,转到文件 A 的 <Content Include>(或 <None Include>,或者您有什么)节点并向其添加一个 <DependentUpon>File B</DependentUpon> 子节点。结果应与此类似:

<Content Include="File A">
  <DependentUpon>File B</DependentUpon>
</Content>`