Answer the question
In order to leave comments, you need to log in
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
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.
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 questionAsk a Question
731 491 924 answers to any question