You know how Visual Stu­dio neatly col­lates all the rel­e­vant files (the XAML and the code behind file in this case) for you when­ever you cre­ate a new user con­trol or page in WPF:

image

need­less to say, in any siz­able UI project this makes life hell of a lot eas­ier nav­i­gat­ing through the solution!

How­ever, the same sup­port is sadly lack­ing for nor­mal par­tial class files.. for instance, if I ever wanted to slice up my class into par­tial classes in sep­a­rate files to bet­ter orga­nize (and make perus­ing eas­ier) a bloated class file:

image

Visual Stu­dio by default doesn’t col­late the par­tial class files for you, but there’s a quick and easy (albeit man­ual) way to do this your­self in a few steps:

1. unload the project and edit the .csproj file

image

2. edit the entries for the files you want to col­late to add a Depen­den­tUpon child ele­ment, e.g.

image

3. save, and reload project

image

Voila!

Share

One Response to “.Net Tips – Collating partial class files”

  1. […] is still com­piled into a sin­gle type, in a sin­gle project. It does how­ever, allow you to sep­a­rate a huge class file into mul­ti­ple files and hence mak­ing it eas­ier to organ­ise and man­age. May 23, 2011 | theburningmonk | […]

Leave a Reply