Prism RegionManager.Region ["]. GetView (" string ") always returns null

I have an import in my view model for regionmanager

[Import] private IRegionManager _regionManager; 

I want to be able to get a view and remove it from the area.

The first step is to get an idea that is.

 _regionManager.Regions["MainRegion"].GetView("ViewName"); 

Everything I do always returns null. I specify a name for my view when adding it using view insertion. When I try to use the above method, although it does not work. I saw other posts on this subject, but no one seems to explain how to resolve it.

+2
wpf mef prism
source share
1 answer

I figured it out. Misunderstanding on my part.

When I added a view to my region, I used

 View myView = new myView(); myView.Name = "ABC"; _regionManager.Regions["MainRegion"].Add(myView); 

This did not work when I tried GetView ("ABC")

I had to do the following:

 _regionManager.Regions["MainRegion"].Add(myView, "asdf"); 

and then later I can call

 _regionManager.Regions["MainRegion"].GetView("asdf"); 
+2
source share

All Articles