How to create a class that will be under of a class in solution explorer?

1.8k views Asked by At

First I created a class file named Bootstrap.cs, then I created another class name Bootstrap.Designer.cs, the awesome part is Bootstrap.Designer.cs become under of first class.

Bootstrap.Designer.cs

So I decide to create another class called Bootstrap.Sample.cs

enter image description here

But the problem here is the third class not become under of first class.

Is there any list of class naming exist like *.Designer.cs that allowed to be under of first class?

2

There are 2 answers

0
Greg the Incredulous On BEST ANSWER

You can do this using VSCommands plugin for Visual Studio. Simply highlight the two files, right click in Solution Explorer, and choose group.

If you want to do it manually you can right click on your project file in solution explorer, choose Unload Project. Then you can right click and edit the project, which will allow you to see the underlying XML. You're looking for

<Compile Include="yourfilename.cs" />

which you will need to change to

<Compile Include="yourfilename.cs">
   <DependentUpon>parentFile.cs</DependentUpon>
</Compile>

This is described in How to group partial class files in Solution Explorer VS2010

1
Craig W. On

There's a file nesting extension in the Visual Studio gallery that allows you to nest/un-nest files in Solution Explorer. It also lets you set up naming rules so files that conform to certain naming conventions will automatically be nested.

https://visualstudiogallery.msdn.microsoft.com/3ebde8fb-26d8-4374-a0eb-1e4e2665070c