C# 如何在Shell中向Tabcontrol添加视图的新副本?
MEF+目录目录+OnDemand 我在ModuleB中有一个代码Initialize():C# 如何在Shell中向Tabcontrol添加视图的新副本?,c#,wpf,prism,tabcontrol,C#,Wpf,Prism,Tabcontrol,MEF+目录目录+OnDemand 我在ModuleB中有一个代码Initialize(): this.regionManager.AddToRegion("TabRegion", new Views.Container()); this.regionManager.AddToRegion("TabRegion", new Views.Container()); 然后单击Shell上的事件: modulemanager.LoadModule("ModuleB"); 因此,我在shell ta
this.regionManager.AddToRegion("TabRegion", new Views.Container());
this.regionManager.AddToRegion("TabRegion", new Views.Container());
然后单击Shell上的事件:
modulemanager.LoadModule("ModuleB");
因此,我在shell tabcontrol中看到了两个选项卡
对我来说,问题是再次打电话:
this.regionManager.AddToRegion("TabRegion", new Views.Container());
怎么做?
非常感谢
PS
我试图在web上找到解决方案,但我想我的问题是不正确的。如果此代码仅从ModuleB构造函数(或某些嵌套方法)调用,那么您唯一的方法就是创建另一个ModuleB实例。以下是一篇可能对您有所帮助的文章:
但是如果您可以将该方法设置为静态,那么您可以根据需要随时调用它。使用EventAggregator:
public Shell(IEventAggregator _eventaggregator);
eventaggregator.GetEvent().Publish("STOCK0");
eventaggregator.GetEvent().Subscribe(CreateView);
this.regionManager.AddToRegion("TabRegion", new Views.Container());
链接到同一个问题和答案如果你对你的解决方案做出一个答案,然后将其标记为答案(点击空心复选标记)会更好。这对我来说是个惊喜,有人编辑了我的帖子!谢谢,顺便说一下,我将编辑一些代码样式。stackoverflow设置为有好的、社区维护的问题和答案,因此任何人都可以编辑任何帖子(尽管如果他们编辑得不好,其他人会撤销)。请不要删除答案中的链接!