What should be done in the [Name] View.xaml.cs files?

I am building a desktop application using WPF and Caliburn MVVM. In my Views directory, I have several files that follow this pattern:

ExampleView.xaml <= this is the actual user interface design ...

ExampleView.xaml.cs <= what is happening here?

Then I also have a ViewModel for each view.

Can someone explain what should go in ExampleViewModel.cs and what should go in ExampleView.xaml.cs? It looks like my ViewModels are inheriting from "Screen", where my ExampleView.xaml.cs is inheriting from "Window".

Thanks!

+4
source share
3 answers

"Codebehind" . . , , MVVM, viewmodel. MVVM .

, : ExampleView.xaml.cs .

+1

, Window UserControl WPF. MVVM , - , . MVC MVP MVVM . .

UI-, ViewModel. ​​ [Name] View.xaml.cs ( ), OnLoad, OnResize. .

+1

WPF MVVMLight Nuget, [views].aspx.cs . - , . - 8 MVVM .

The only time I put something in the view code is perhaps to create an instance of the view model to go with this view in very isolated situations.

There is much debate about whether you need to have zero code to follow MVVM best or to have some code in the code behind. Personal preferences and based on workload, complexity, timing, etc.

0
source

Source: https://habr.com/ru/post/1623133/


All Articles