Reputation: 5815
we are designing a xbap application that has complex, user configurable navigation flow that depend on state of the model\user security etc and some other environmental factors.
The application is having a container view that loads user specific controls inside a Frame, i am wondering whats the preferred practice for having the navigation logic, inside a separate controller or in the viewmodel of the container view..
Upvotes: 3
Views: 4560
Reputation: 1068
Drew, any chance of getting a bit more explanation on that. I like that 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 navigate next.
Upvotes: 0
Reputation: 1513
I would put the navigation flow code in a global controller or service of some kind. You probably don't want your views or view models to have such logic because they would pull quite a lot of dependencies to them, especially if your flow is quite complex and customizable. Instead, you want those views and view models to be easily unit-testable, in which case they would defer what happens when they're done to somebody who's in a better position to make the appropriate decision.
Upvotes: 2
Reputation: 33379
I would think that hooking up a top level routed event handler for Hyperlink.RequestNavigate and a CommandBinding for NavigationCommands.GoToPage would be a sufficient level of separation. Were you looking for more?
Upvotes: 1