Prism RegionManager.Region [“"].GetView("string")始终返回null [英] Prism RegionManager.Region[""].GetView("string") always returns null

查看:305
本文介绍了Prism RegionManager.Region [“"].GetView("string")始终返回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.

第一步,获取视图 即

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

无论我做什么,都始终返回null.使用视图注入添加视图时,我为视图指定了名称.当我尝试使用上述方法时,尽管它不起作用.我看过其他有关此问题的文章,但似乎都没有任何文章解释如何解决.

Whatever I do this always 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);

当我尝试GetView("ABC")时这不起作用

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

我应该做的如下

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

然后我可以打电话

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

这篇关于Prism RegionManager.Region [“"].GetView("string")始终返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆