gsi*_*ank 13 xaml computer-science folding visual-studio
如何将我的ViewModel文件(.cs文件)折叠在其对应的View文件(.xaml文件)文件中,如图像中所示?
Ken*_*nde 18
我不知道在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>
Run Code Online (Sandbox Code Playgroud)
这两个标签可能不在您的文件中彼此相邻.<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>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4916 次 |
最近记录: |