Creating Template Items that have nested appearance in the Solution Explorer

January 25, 2008

In a previous post of mine I mentioned the lack of being to select some items in the solution explorer and making them nested.

I believe this to be serious functionality for the Visual Studio especially for large projects using partial classes.

Finally I found how is done programmatically and not only that I implemented it on a Custom Project Item Template.

Being my blog not all that known for obvious reasons, I have decided to post all the knowledge in CodeProject. The article is this and I hope you find useful.


Visual Studio 2008 nested class representation

December 26, 2007

I was playing with Visual Studio Solution Explorer, and one of the things I wished Microsoft had fixed from Visual Studio 2005, was the ability to select classes with names

  • Class1.cs
  • Class1.Input.cs
  • Class1.Output.cs

and make them appear as a tree, like Solution Explorer does with DataSet classes and Forms and Controls.

But I couldn’t find anything.

I know how to implement the feature manually, but I don’t see the point. In Visual Studio 2005 I had tried to create a template for a pack of 3 files like the above for example, but in the templates xml file, there was no DependsUpon tag to allow such a trick.

From what I understand, Solution Explorer has an automatic mechanism about this feature, because when I had a Class1.cs in my solution, and then added a Class1.Designer.cs it automatically implemented the trick.

Can’t there be a standard that ClassName.*.cs will hang below ClassName.cs? It would be very useful.