Prism RegionManager.Region[""].GetView("string") always returns null
I have an import in my view model for the regionmanager
[Import]
private IRegionManager _regionManager;
I want to be able to get a view and remove it from a region.
First step, get the view i.e.
_regionManager.Regions["MainRegion"].GetView("ViewName");
Whatever I do this alway开发者_Python百科s returns null. I specify a name for my view when adding it using view injection. When I try to use the above method though it doesn't work. I've seen other posts regarding this matter but none that seem to explain how to resolve it.
I have sorted it out. Misunderstanding on my part.
When I was adding the view to my region I was using
View myView = new myView();
myView.Name = "ABC";
_regionManager.Regions["MainRegion"].Add(myView);
This did not work when I tried GetView("ABC")
What I should have done was as follows
_regionManager.Regions["MainRegion"].Add(myView, "asdf");
and then later on I can call
_regionManager.Regions["MainRegion"].GetView("asdf");
精彩评论