idev
idev

Reputation: 11

Sharing viewmodel to multiple views using Caliburn.Micro in WP7

I am currently working on a project which requires multiple views of the same viewmodel. Let me describe this way:

I am currently using NavigationService to navigate to CustomerInfo view. Is there any way to pass the reference of current viewmodel to the view which user is navigating to in caliburn.micro?

Thanks in advance

idev

Upvotes: 1

Views: 3207

Answers (2)

lukebuehler
lukebuehler

Reputation: 4071

Use the attached property cal:Bind.Model="{Binding}" to bind the view to the view model. See http://caliburnmicro.codeplex.com/wikipage?title=All%20About%20Actions "View First" section.

Alternatively you can also look into the cal:View.Context="MyContext" attached property as described here: http://caliburnmicro.codeplex.com/wikipage?title=Screens%2c%20Conductors%20and%20Composition "Multiple Views over the Same ViewModel" section.

Upvotes: 2

Joel
Joel

Reputation: 2361

Add a property or two to your App.xaml.cs. What ever you put in here will persist throughout the lifetime of the application (keep in mind that tombstoning will cause this property's value to be lost though). If you want to pass a ViewModel then setyour associated property in App.xaml.cs to the view model and then when the new page loads have it read from that same property.

Upvotes: 1

Related Questions