I am developing a Prism application and it contains a TabControl
which contains several child regions. Therefore I implemented a custom RegionBehavior, according to the pattern described by Brian Lagunas in his PluralSight course found at https://app.pluralsight.com/library/courses/prism-mastering-tabcontrol/ and injected a custom RegionNavigationContentLoader also described in the aforementioned course, to make sure I get no exceptions and can have regions of the same name on several tabs of my TabControl.
For those who have no access to PluralSight:
I implemented a behavior that monitors the Views-collection of a region, and, when it changes, checks, whether the added view or its DataContext implements a specific interface. If this interface is detected, it sets the scoped RegionManager to a property of that interface, so all views that go into a scoped region can be aware of their scoped RegionManager.
However, I also have some services that require this scoped RegionManager in order to navigate to a child region inside my TabControl.
Since I am creating this service in my container, it gets the global RegionManager injected instead of the scoped one.
My questions are:
- Are there any patterns or structures that allow for injecting scoped RegionManagers into services?
- If the answer to 1 is no, should services navigate to regions anyway or is this a bad idea?
Update
Below you find the planned structure of my application. I hope it makes clear why I want to navigate to a scoped region from within a service:
The application consists of a TabControl
as already mentioned, where each of the TabItems contains an analysis.
An analyis always consists of a selected visualisation which can be selected in the upper right box. When a visualisation is selected it gets activated in a service, which mainly calls code to generate the visualisation, checks for validity of settings etc.
Then the visualisation should be shown in the VisualisationRegion and the visualisation-specific settings should be shown in the SettingsRegion.
My plan was to navigate to those two regions from within the service.
Since the visualisations can not be generated beforehand (there are checks that must always be executed prior display I can not navigate directly from the view/viewmodel. Even if that was possible the view displaying all the visualisation types is not aware of the scoped RegionManager, since it is part of a composed view (the parent view is aware and could of course inject the scoped RegionManager into its child view, but that seems to me like a code smell)
Is this type of application maybe not suitable for Prisms navigation approach or do you have an idea how I could restructure my application to better fit with Prism?