Get VS2008 to “tree-indent” partial classes (like code-behind files)

邮差的信 提交于 2019-12-08 17:41:55

问题


I have created a multi plattform project, and everything works nicely, except one little things. When I add a specific plattform file, like:

  • ServiceImpl.cs
  • ServiceImpl.Desktop.cs

it does not show up nicely in a tree fashion like in this article:

Multi-Targeting (check the last image in the article to understand what I mean)..

Any ideas how to "teach" VS 2008 to do this? With normal XAML and Code-Behind it works as usual...


Ok, the answer worked perfect for a normal situation. Now, there is still a little problem with the silverlight project. The file is originally located in the desktop project, so there the solution works. However, if the "parent" file is a link, it seems to cause a problem (no effect at all)... See this code:

<Compile Include="..\Messaging\Services\MessagingService.cs">
  <Link>Services\MessagingService.cs</Link>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Services\MessagingService.Silverlight.cs">
      <DependentUpon>MessagingService.cs</DependentUpon>
</Compile>

Any ideas for this situation?


回答1:


It doesn't always do it automatically (although it spots things like .Designer.), but you can edit the csproj by hand to do this (it is just xml). There are also a few add-ins that provide this, but the one I use has been removed. You want DependentUpon...

<Compile Include="ServiceImpl.cs" />
<Compile Include="ServiceImpl.Desktop.cs">
  <DependentUpon>ServiceImpl.cs</DependentUpon>
</Compile>

(note they must be in the same folder; you don't specify the folder in DependentUpon)




回答2:


You can use this plugin http://mokosh.co.uk/vscommands/ to group items in solution explorer from VS (without editing project file).



来源:https://stackoverflow.com/questions/1043467/get-vs2008-to-tree-indent-partial-classes-like-code-behind-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!