如何将我的 ViewModel 文件(.cs 文件)折叠到其相应的 View 文件(.xaml 文件)文件中,如图所示?
我不知道在 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>
tag.
在您的文件中,找到带有以下内容的标签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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)