Prism: Share data between ViewModels loaded into a region?

◇◆丶佛笑我妖孽 提交于 2019-12-10 02:16:02

问题


I've got a View containing a TabControl bound to a region "CustomerRegion".

I've got a few View/ViewModels which are marked as [ViewExport(RegionName = "CustomerRegion")].

These items are loaded successfully into the TabControl.

But now I need these TabItems to share some data in this TabControl (can't be global since there might be two or more of these open at one time).

Any ideas how these TabItems can share data without leaving MVVM/MEF?


回答1:


Prism has the concept of "Region Context" that you might be able to use, depending on your scenario.

Check out the Prism Region documentation and look for the section entitled "Sharing Data Between Multiple Regions" (though this title is a little misleading...).

If you find this doesn't work for you, I would suggest writing a custom inheriting attached property that you can bind to from subviews and modify from the parent view.



来源:https://stackoverflow.com/questions/4408747/prism-share-data-between-viewmodels-loaded-into-a-region

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!