C
C#2y ago
Davaaron

❔ Prism: Change view in region - How to add multiple views to region and activate?

Hey, currently I'm developing a WPF application that has a navigation menu on the left (basically a treeview) and a content panel on the right. Whenever I click on a treeview item, the details about that item should be displayed on the right side within the content panel. There are different types of items and each type has a view and a viewmodel. How do I add multiple views to a region and activate one at a time? I added the views like this
var regionmanager = Container.Resolve<IRegionManager>();
regionmanager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(PersonDetails));
regionmanager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(Overview));
var regionmanager = Container.Resolve<IRegionManager>();
regionmanager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(PersonDetails));
regionmanager.RegisterViewWithRegion(RegionNames.ContentRegion, typeof(Overview));
and PersonDetails is showed. When I run
RegionManager.Regions[RegionNames.ContentRegion].Activate(typeof(Overview));
RegionManager.Regions[RegionNames.ContentRegion].Activate(typeof(Overview));
I get an error
This RegionManager does not contain a Region with the name
This RegionManager does not contain a Region with the name
When I exchange "RegisterViewWithRegion" by "AddToRegion" I get another exception. What's wrong here?
2 Replies
Davaaron
DavaaronOP2y ago
Got it
Accord
Accord2y ago
Looks like nothing has happened here. I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server