0

RequestNavigate(uri) is nice when you want to navigate to region using a string and immediately make it the active view. But what if you want to add a region without activating it? Is there a way to do that with a string?

I have a view model that needs to add some views to a docking control dynamically. These views should not be activated when they are added. Adding a region using Region.Add works but I have to give it a type:

RegionManager.Regions[KnownRegionNames.DockingRegion].Add(typeof(MyView));

I feel like this violates some MVVM principals of making the ViewModel completely independent from views. It's not absolutely terrible since I can probably mock out the region manager in testing, but is there another way?

Ben Zuill-Smith
  • 3,504
  • 3
  • 25
  • 44

1 Answers1

0

You'll have to somehow identify the view you want to add to your region, either by type or by string.

You can use the string to resolve it from the container (basically what the region manager does) and add the resolved view to the region.

Haukinger
  • 10,420
  • 2
  • 15
  • 28