开发者

Prism: Share data between ViewModels loaded into a region?

开发者 https://www.devze.com 2023-01-29 16:51 出处:网络
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\")].

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 TabCon开发者_开发问答trol (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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消