获取VS2008到"树缩进"的部分类(如代码隐藏文件)

Chr*_*ert 7 code-behind visual-studio-2008

我已经创建了一个多平台项目,除了一件小事之外,一切都很顺利.当我添加特定的平台文件时,例如:

  • ServiceImpl.cs
  • ServiceImpl.Desktop.cs

它没有像本文中那样以树形方式很好地显示:

多目标(查看文章中的最后一张图片,了解我的意思)..

任何想法如何"教"VS 2008这样做?使用普通的XAML和Code-Behind,它可以正常工作......


好的,答案对于正常情况来说是完美的.现在,Silverlight项目仍然存在一些问题.该文件最初位于桌面项目中,因此解决方案有效.但是,如果"父"文件是一个链接,它似乎会导致问题(根本没有效果)...请参阅此代码:

<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>
Run Code Online (Sandbox Code Playgroud)

对于这种情况的任何想法?

Mar*_*ell 10

它并不总是自动执行(虽然它会发现像.Designer这样的东西.),但是您可以手动编辑csproj来执行此操作(它只是xml).还有一些加载项提供了这个,但我使用的加载项已被删除.你想要DependentUpon ...

<Compile Include="ServiceImpl.cs" />
<Compile Include="ServiceImpl.Desktop.cs">
  <DependentUpon>ServiceImpl.cs</DependentUpon>
</Compile>
Run Code Online (Sandbox Code Playgroud)

(注意它们必须位于同一文件夹中;您不在DependentUpon中指定文件夹)