且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

Prism RegionAdapter-删除然后添加视图

更新时间:2023-12-05 21:58:28

我处理Closing事件,而不是处理Closed事件(可能会丢失对基础视图的引用).

Instead of handling the Closed event (which may have lost a reference to the underlying view), I handle the Closing event.

这可行,但是,当我尝试重新打开选项卡时,它显示的是同一实例.阅读此内容后,在复合WPF中 (Prism),IRegion.Add和IRegionManager.RegisterViewWithRegion有什么区别?我对此进行了更改:

This worked, however, when I tried to re-open the tab, it was displaying the same instance. After reading this In Composite WPF (Prism), what is the difference between IRegion.Add and IRegionManager.RegisterViewWithRegion? I changed this:

_regionManager.RegisterViewWithRegion("MainRegion", typeof(Views.ClassicFrontierView));

对此:

_regionManager.Regions["MainRegion"].Add(new Classic.Views.ClassicFrontierView());

我仍然必须对Prism/avalondock进行一些研究,以确保不会出现内存泄漏,但到目前为止,它似乎仍在工作.

I still have to do some research with Prism / avalondock to make sure there will be no memory leaks, but as of now it appears to be working.