This project has moved and is read-only. For the latest updates, please go here.

Binding View & View models from 2 different xaps

Oct 23, 2011 at 7:08 PM

Hi Jeremy, 

In Jounce, Is it possible to pull in a View from XAP2 and associate a ViewModel from XAP3 and display the same in XAP1. 

Currently we know that we can pull in the View from different xap(XAP2) and display the view in XAP1. 

If possible, can u let me know how to do that?


Oct 27, 2011 at 2:18 PM

It is entirely possible but you just have to make sure you set up routes correctly and (a) load XAP2 when needed and (b) use appropriate tags for the routing so you're not dependent on the type as it's not referenceable at that time. I'm confused why you would want the VM which essentially synchronizes view state and presentation logic in a separate XAP from the view that implements it?

Oct 28, 2011 at 6:53 PM

Hi Jeremy, 

The reason i want to bind View - ViewModel from 2 different xaps are

1) we have a common UI which binds data from many different sources. We have the common UI as Views in one xap and consume the data from different xaps. rather than having a seperate views per xap, we encapsulate the Views in one module and retrieve the data from other xaps through multiple viewmodels. Hope that looks sensible. If you would provide an better approach for this scenario, i would rather be very happy to take it. 

2) Do i need to explicitly pull the ViewModel XAPs through Ideploymentservice or is it something that is possible through ViewXAPRouter(may be ViewModelXAPRouter)?

Your views on this. 



Oct 31, 2011 at 1:34 PM

Sure ... it would be difficult for me to recommend/suggest anything without knowing your system in more detail - that's fine, I understand what you're saying. Out of the box, Jounce provides the routes for views in different XAP files but not view models, so you are correct in the assumption that you would need to use the IDeploymentService to load the XAP with the view model, then either use a module initializer to expose the route or call on the fluent configuration featuers of the router.