How to make (.cs) code files expand / collapse underneath another code file in Visual Studio solution explorer?
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.
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>
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.
精彩评论