在MVVM为什么人们正在创建一个视图模型文件夹?视图、创建一个、文件夹、模型

2023-09-07 09:07:06 作者:百秒少年

...使用xxx.xaml.cs的这一翻译生成的文件?

... intead of using the xxx.xaml.cs generated file?

开发人员正在创建XAML视图中查看文件夹中。 Visual Studio中生成xaml.cs文件刚下XAML文件。但开发商preFER创建一个新的文件夹视图模型,并为每个XXX XAML文件他们创造一个xxxViewModel.cs文件。为什么不将这些的ViewModels的所有内容在xxx.xaml.cs文件?

Developer are creating a View in xaml in the Views folder. Visual Studio generate the xaml.cs file just under the xaml file. But developer prefer creating a new folder ViewModel and for each xxx xaml file they create a xxxViewModel.cs file. Why don't move all the content of these ViewModels in the xxx.xaml.cs file?

推荐答案

有些人甚至喜欢窝在视图模型直接 XAML在文件,像

Some people even like to nest the ViewModel directly under the xaml file, like

这可以通过使用此自定义的Visual Studio扩展来实现

This can be done by using this custom Visual Studio extension: NestIn