Prism and MVVM for the new WPF project

In the near future I will start a new project and I will look for advice on architecture from those of you who have experience with WPF, Prism and MVVM.

The project will certainly be WPF, and I will implement MVVM (I will most likely use the Josh Smith MVVM Foundation as a starting point) to be able to benefit from the separation of UI / logic, etc. I'm not sure, although if it were useful for me to use Prism to structure my project.

Let me briefly describe the project. There will be a main "toolbar" on which a number of widgets will be displayed. Each widget displays some basic data related to its function, and clicking the widget will open a new window in which much more detailed data will be displayed and contain a rich user interface for viewing / editing data.

Now I thought that I could use Prism to create a project, but I had never used it before and was not sure if it was suitable for what I was trying to achieve. For example, will my โ€œtoolbarโ€ be a wrapper containing regions to be filled with each widget? Will each new window displayed when the widget is clicked also be its own shell with its own region setting? If I can get a template for the toolbar and one widget in the toolbar, I can replicate it for the rest of the widgets.

Besides Prism, I have a question about how MVVM should be implemented for certain data editing windows. Let's say I have a chart that displays some data, and the user can directly click / mouse on the chart to edit the data that he sees. All data is in the model, and the presentation model makes this data available for viewing through binding. My question is, where will the mouse clicks or events that relate to the chart in this view be recorded? We donโ€™t need much / nothing in the review code, and we donโ€™t want to have UI event handlers in the view model, so I'm not sure how this type of script is handled. I know that commands are the likely answer here, but the MVVM samples I've seen areusually show example commands for simple button presses. Is the general idea the same?

, - - WPF MVVM/Prism, .

.

+3
2

, , .

, WPF, MVVM Prism . , . Prism, .

...

  • Shell bootstrapper .
  • Unity . DI. , .
  • EventAggregator ,
  • , .

4 , MVVM/WPF.

, " " , , ?

, ( ), . ( ). , / ( ), ViewModel. .

, ?

, , , . , , , . ...

<Window ...>
  <ContentControl Content="{Binding}" />
</Window> 

...

public void DisplayView(ViewModel vm)
{
   var window = new MyWindow { DataContext = vm };
   window.Show();
}

... testabilty . , Applicaiton.Resources DataTemplate, .

: / , , ?

, EventToCommand , , MVVMLight , , .

DI , Prism, .

+4

, .

- > , , ?

  • ItemsControl
  • .

, , .

- > , , ?

, "WindowRegionAdapter" .

- > / , ?

ViewModel XAML. Google "Blend behaviors" " bahaviors" , . .

, , , .

+1

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


All Articles