Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prism: Share data between ViewModels loaded into a region?

Tags:

mvvm

mef

prism

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?

like image 365
Sam Avatar asked Dec 10 '10 12:12

Sam


1 Answers

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.

like image 104
Anderson Imes Avatar answered Oct 09 '22 04:10

Anderson Imes