0

I am working on a personal project. I started with a previous post (Point of Sale Application Architecture).

Trying to Use- repository - service and View Modal - View approach

Please see the attached image file. Most of my windows will have multiple views.

My Questions are:

  1. Looking at the windows do you think my project is a good candidate for CAG (Prism) or is it an overkill
  2. Will I be able to get POPUp modal windows and communicate to them from its parent view- region-module.
  3. Multiple Windows in Prism ( assuming that I can create multiple shell) , Is communication between them complex
  4. read on SO about creating complex views with sub views as properties. Is this a good approach or will too much code

The more I look into applying some pattern more I am getting confused

I am sure there are some of you had similar issues and may be your approach might solve things for me.

Thank you Mar

http://www.flickr.com/photos/themarworld/3820178039/ http://www.flickr.com/photos/themarworld/3820178039/

Community
  • 1
  • 1
TheMar
  • 1,934
  • 2
  • 30
  • 51
  • Just a thought. Can we rearrage regions in a shell (left top width height visible ). Can I have nested regions Then may be I only need only one shell and can have views load into regions as necessary. Got this idea after looking at Woodgrove financial application demo @ http://scorbs.com/workapps/woodgrove/FinanceApplication.xbap – TheMar Aug 14 '09 at 18:36
  • This seems to help in what I am looking for -http://www.codeplex.com/CompositeWPFContrib – TheMar Aug 14 '09 at 19:01
  • add a link to flickr image as not sure how to insert one – TheMar Aug 15 '09 at 17:44

2 Answers2

1

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.

lesscode
  • 6,221
  • 30
  • 58
  • 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 Aug 15 '09 at 17:42
  • 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. – lesscode Aug 19 '09 at 02:25
1

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
  • 25,500
  • 4
  • 67
  • 82
  • 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. – lesscode Aug 19 '09 at 02:31
  • 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 Aug 19 '09 at 21:15
  • 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 Aug 28 '09 at 15:27
  • 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 Aug 28 '09 at 17:48