views:

443

answers:

2
+1  A: 

I can't see your screenshot but I can give you a little direction here. I've been setting up the shell of a multi-targetted (WPF/Silverlight) composite app recently, learning the libraries as I go.

  1. "Most of my windows will have multiple views." -- this by itself probably means you'll like what you find in the Composite Application Library. And MVVM is a perfect pattern for the CAL. In the StockTrader reference application they use the term PresentationModel, but this is essentially the same thing as MVVM.

  2. Popup modals work great in both WPF and SL (via the Toolkit extension ChildWindow control). You'd communicate with them in same way you would a regular region - by injecting views and services. What I found particularly neat about this is that you can define a region in a popup, register views with it when the app (module) is loaded (even though the region itself is not yet loaded), and then when the region pops up the correct views are injected at that point. In other words you don't have to get involved in deferring the injection of the view until the region is displayed, which I was expecting to have to do.

  3. Haven't tried this -- can't comment.

  4. Not sure about "sub-views", but regions within regions is certainly possible.

Wayne
Thank you Wayne. will see why the image is not showing. Good point that I should learn the library as development proceeds. I am going ahead with CAL. I was worried if communicah tion is going to be an issue. Have you had any experience using Feb 2009 release CAL and Toolkit
TheMar
Yes, I'm using the Feb release -- also I waited until SL3 before starting my project because I wanted a multi-target solution and there are a few improvements and fixes in SL3 regarding the CAL.
Wayne
Thank you Wayne for the information
TheMar
+1  A: 

Wayne has good answers for #1 and #2... I'll get #3 and #4.

3) Communication between views that don't share the same view model is done through the EventAggregator in Prism. It's a very easy to use Publisher Subscriber model for messages. You'll have no trouble understanding this.

4) I don't like the idea of having a view as a property of a view model. It's a problem of separation of concerns. You're shooting for your ViewModels to be interface agnostic and this would imply too much interface leaking into your viewmodels. 2 acceptable alternatives would be

  • Sub ViewModels as properties of your ViewModel. You could use DataTemplates to provide the look to them without specifying the UI in the ViewModel.
  • Sub Regions. This is a perfectly acceptable. Sometimes it can get tricky depending on your UI because you'll end up trying to keep track of your RegionManager scopes, but it's doable.

HTH, Anderson

Anderson Imes
Anderson, re 4)Are you doing View-first instantiation and injecting a ViewModel?I was nervous about having ViewModels reference Views also, but the StockTraderRI uses the ViewModel-first approach, which requires the model to hold a reference to the view as far as I can tell. Did you come up against any significant "leakage" problems with ViewModel-first? It's still early in development for our project so we've time to switch if I can find a compelling reason.
Wayne
We create the views and the viewmodels seperately and marry them by settings DataContext. I don't see a good reason they should ever directly reference each other and I think the ViewModel having a reference to the view is definitely a violation. Anything you need to do that would require the ViewModel to have a reference to a view you can workaround. Most of that stuff you can find on either Josh Smith or Marlon Grech's websites.
Anderson Imes
Thank you guys. I think I am getting knack of Prism. There is so much information on these things which was too much for my small brain. So I got started on the project. I do reference view in view model but that is to get few things working as of now and as time passes I will remove references. I am moving ahead with the idea that If I can get one module up and running and implement the best practices then rest will fall in place. Josh Smith or Marlon Grech's blogs are great I keep referencing them.
TheMar
As a note... your question about View first, vs. ViewModel first (and when and how to instantiate each) came up in a Herding Code episode. Thought you might want to listen to it. http://herdingcode.com/?p=208
Anderson Imes