12
如何将我的ViewModel文件(一个.cs文件)折叠到其对应的View文件(.xaml文件)文件中,就像在图像中一样?如何在Visual Studio 2010中的.xaml文件中折叠.cs文件?
如何将我的ViewModel文件(一个.cs文件)折叠到其对应的View文件(.xaml文件)文件中,就像在图像中一样?如何在Visual Studio 2010中的.xaml文件中折叠.cs文件?
我不知道的方式做到这一点在Visual Studio中,但你可以在文本编辑器编辑.csproj的文件。你应该找到这样的东西:
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
这两个标记可能并不紧挨着在你的文件中。重要的部分是<DependantUpon>
标签。
在您的文件中,找到具有include="ViewModel.cs"
属性的标记。在此标签内部,将<DependantUpon>View.xaml</DependantUpon>
作为子元素添加。现在,您的ViewModel.cs文件将始终位于View.xaml文件的内部。最后,你的文件应该有类似这样的片断,这些东西:
<Page Include="View.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Compile Include="ViewModel.cs">
<DependentUpon>View.xaml</DependentUpon>
</Compile>
见http://stackoverflow.com/questions/3621345/how-to-group-partial-class-files-in-solution- explorer-vs2010的GUI方式来做到这一点 – 2011-02-27 15:34:21
如果有一个默认的GUI方法仍然会很好。似乎从一开始就显而易见。 – 2011-02-27 17:40:36