views:

267

answers:

2

A while ago, I posted a question regarding switching between a Blend-authored GUI and a Visual Studio-authored one. I got it to work okay by adding my Blend project to my VS2008 project and then changing the Startup Application and recompiling. This would result in two applications that had completely different GUIs, yet used the exact same ViewModel and Model code. I was pretty happy with that.

Now that I've learned about the Laurent Bugnion's MVVM Light Toolkit, I would really like to leverage his efforts to make this process of supporting multiple GUIs for the same backend code possible. The question is, does the toolkit facilate this, or am I stuck doing it my previous way?

I've watched his video from MIX10 and have read some of the articles about it online. However, I've yet to see something that indicates that there is a clean way to allow a user to either dynamically switch GUIs on the fly by loading a different DLL. There are MVVM templates for VS2008 and Blend 3, but am I supposed to create both types of projects for my application and then reference specific files from my VS2008 solution?

UPDATE I re-read some information on Laurent's site, and seemed to have forgotten that the whole point of the template was to allow the same solution to be opened in VS2008 and Blend. So anyhow, with this new perspective it looks like the templates are actually intended to use a single GUI, most likely designed entirely in Blend (with the convenience of debugging through VS2008), and then be able to use two different ViewModels -- one for design-time, and one for runtime.

So it seems to me like the answer to my question is that I want to use a combination of my previous solution, along with the MVVM Light Toolkit. The former will allow me to make multiple, distinct GUIs around my core code, while the latter will make designing fancy GUIs in Blend easier with the usage of a design-time ViewModel. Can anyone comment on this?

A: 

I think MEFedMVVM would be a good candidate for this. It is simple and you can combine it with other frameworks.

bitbonk
thanks, but I would really like to stick to the MVVM Light Toolkit, since I already am using MEF in my application, and I also plan to use RelayCommand and Messenger from Laurent's toolkit.
Dave
+1  A: 

Hi,

I checked your previous question and this one, and I had never really heard about switching projects to work in Blend and in Studio, and end up with two different UIs. I think this was not the intent of MSFT when they built Blend. Instead, the possibility to open the exact same project and code files in both IDEs (and all the discussions I had with the various teams at MSFT) hints that the intent was in fact to have one application only which can be edited in both environments.

I think that in the end, the goal is to have a variety of tools that you can use to edit your UI - XAML, Visual Studio designer, Blend. Depending on your role in the project (developer, designer, integrator) and depending on your ability with the tools, you can choose one or the other.

This doesn't mean that we never switch templates! Depending on the kind of application (for example between a SL4 desktop application or a WinPhone7 application), we use the same ViewModel (and below) code, but slap a different UI altogether on the files. I demoed how to do that in this video: http://channel9.msdn.com/posts/kreekman/TechDays-2010-Understanding-the-Model-View-ViewModel-pattern/

This is the same talk I gave at MIX but extended by 15 minutes where I show how to reuse the ViewModel and model files, but use a completely different UI for WinPhone7.

Another application is switching templates when a window is resized (used very often in WPF, but also applicable to Silverlight) in order to show less details or a different layout for different screen sizes.

I hope that this reply doesn't confuse you :) and in fact, I'd love to hear your comments on that before we continue the discussion.

Cheers, Laurent

LBugnion
Hi Laurent, thanks for responding! Your first paragraph confirms what I had realized, so that's good. It totally makes sense, and I think it's great to be able to open the solution in both applications and have it work. Before your toolkit and templates, I would end up with design-time exceptions, or no representative GUI, period. I am downloading your talk now -- thanks for posting it. What you are talking about is closest to what I am trying to accomplish, but I am not to targeting different platforms. I will write more later after I watch the video. :)
Dave
Laurent, that was a much more comprehensive video than your MIX10 video! :) The last part with Windows Phone was very informative. Basically, I think it's the same thing I had done before in my previous attempt to support multiple GUIs for the same code. You created a Phone project and added links to your sources, whereas I had created another WPF project, but then added references to the libraries used by my original WPF application. I think I am on the right track now. Thanks again for your input!
Dave
LBugnion