MVVM-based application navigation

we are developing an xbap application that has a complex user-customizable navigation stream that depends on the state of the model \ user security, etc. and some other environmental factors.

The application has a container view that loads user controls inside the frame; I wonder what preferred practice is for the navigation logic inside a separate controller or in the view mode of the container view.

+3
source share
3 answers

I would put the navigation flow code in a global controller or service. You probably do not want your views or view models to have this logic, because they could take quite a few dependencies, especially if your stream is quite complex and customizable. Instead, you want these views and view models to be easily tested by unit, in which case they would put off what happens when they are done with someone who is in a better position to make an appropriate decision.

+2
source

Drew, any chance of getting a little more explanation about this. I like this solution, but I’m learning and don’t quite understand how to put it into practice, especially if there is special logic in the viewModel to determine where to go next.

0
source

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


All Articles