M
M
Matisumi2017-08-04 23:02:22
.NET
Matisumi, 2017-08-04 23:02:22

WPF+MVVM, how to organize window architecture?

I will simplify the real task for an example - there is a window view, in the window there are several buttons and a conditional panel. By clicking on each button in the panel, a form with textboxes, labels, comboboxes, etc. should appear, and each button has its own form.
The question is how to properly organize the architecture of the entire window, taking into account the MVVM pattern and the fact that buttons can / will be added over time, and forms along with them, respectively.
The dumbest option would be to put each form into a separate UserControl, add them in bulk to the main window and just hide / show, but this option seems to me not the most optimal. Perhaps there are more concise options?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
P
Peter, 2017-08-05
@petermzg

Your buttons can be TabControl with custom Template.
And a Frame is added to the TabItem, then its Source will be separate Pages with controls.
You can set all Frame at once in resources, or you can return Uri from ValueConverter.
In the ViewModel, you will simply change the page type and process it in the TabControl -> SelectedItem through the converter.

K
Konstantin Mitreikin, 2017-08-10
@kosmitster

Perhaps in this case one of the WPF frameworks, for example PRISM with its Region Manager, will do.

regionManager.RequestNavigate("ModuleContractorLegalRegion",
                        nameof(LegalScroll.Views.ViewContractorLegalScroll));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question