Defining an element of a project as a sub-element of another

  • Tools

In the solution explorer you can see nested files:

Let's see how to do the same with the two files Class1.cs and Class1.Custom.cs. The trick is in the project file (csproj). You need to look for the Class1.Custom.cs file in it and indicate which item is its parent.

<Compile Include="Class1.cs" />
<Compile Include="Class1.Custom.cs">
    <DependentUpon>Class1.cs</DependentUpon>
</Compile>

And here's the result:

Do you have a question or a suggestion about this post? Contact me on Twitter or by email!

Follow me:
Enjoy this blog?Buy Me A CoffeeDonate with PayPal