I know that i can get all the registered views in a region with :
var vs = mRegionManager.Regions[RegionNames.MainRegionStatic].Views.ToList();
and i can see there is the following code :
mRegionManager.Regions[RegionNames.MainRegionStatic].ActiveViews
which is giving a list of Active View, but I'm having my region attached to a ContentControl which always has a single ActiveView. Am i misunderstood or is there a way to get the single active view?
var singleView = regionManager.Regions["MyRegion"].ActiveViews.FirstOrDefault();
var singleView = regionManager.Regions["MyRegion"].ActiveViews.FirstOrDefault();
This is not correct, as it will just bring whatever view that got activated first. not the currently active/visible view.
Can't find a direct solution though, that doesn't involve custom implementation on View or ViewModel.
Well, you could use the NavigationService Journal. It takes record of all the navigation that takes place in your application. So, you can get the name of the view like this:
string name = mRegionManager.Regions[RegionNames.MainRegionStatic].NavigationService.Journal.CurrentEntry.Uri;
Then you can get the view like this:
mRegionManager.Regions[RegionNames.MainRegionStatic].GetView(name);
Sweet Right? :)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With