WPF and Silverlight in the same solution

Nov 30, 2011 at 7:05 PM
Edited Nov 30, 2011 at 7:08 PM

Hi,

First, great thanks to you Tony for your Simple MVVM Toolkit, it rocks!!  I love the simplicity of your framework, the templates you supply, your videos and your documentation is real good. 

I'm learning a lot with it all and I'm really looking forward to try it more!

 

Here's the concern I have in mind. 

First some background. 

I'm new to MVVM (and using WCF abd WCF Ria Services) and learning about it. I tried a few approaches but with no great success.  

I work for a small company and we are making small custom solutions for our clients, with no reselling of the solution after, it's theirs.  So, our solutions can afford to be more simple and won't change a lot after their done.

I have an idea but I wanted to check out if it was good before investing too much time in it for nothing.

What I had in mind is a solution which integrated views in WPF and inSilverlight (in two different projects), with the possibility of using the same viewModels and services.  

I experimented with a solution like that (from a tutorial I found; you have two different project (one WPF and one Silverlight) and using a link on the viewModel) but I had problems with adding properties to my entities(EF) with a partial class.  The examble was using WCF (not Ria Services, well, as much as I can tell) and I read that WCF doesn't pick up the extra properties added to an entity via a partial class but that Ria Services would do that (maybe it is wrong, but it's what I read on a few blogs).  This is how I found your framework (looked at MVVM Light first, which lead me to your framework and I liked your's better) .

If I stick with Ria Services, is it a good idea to have WPF and Silverlight in the same solution and can it be done? Will I have a problem of some classes not available on one side or the other (Silverlight vs .Net 4.0)?

With the reading I'm doing, I'm getting the idea that maybe WCF Ria Services is more for Silverlight but I don't know if this it true.

So do you think this be done the way your framework works or we would have to build two differents solutions (one WPF and one Silverlight) for something like that?

 

Either way, I'll give your framework a serious try.  It would just be a sweet bonus if the integrated solution idea could work.

Thanks,

Frank

 

 

Dec 1, 2011 at 12:57 PM

Just to clarify, I'm not looking for a long answer here or to have a ready-made solution handed to me...  :) 

I'm not used to posting questions in technical forums either, it's the first time I do.  Maybe my post was too long or maybe it was out of subject, I'm not sure.  Tell me if so, I don't mind, I want to learn the proper way to do it.  I love reading technical forums posts but I think it's about time I participate in them... :)

I just wanted to know if it's a good idea with the SimpleMVVM framework, to have both a WPF project and a Silverlight project in the same VS solution sharing some of the viewModels code or if I should be better with 2 differents solutions, one WPF solution and one Silverlight solution?

A one or two phrases answer is ok.  I'm just looking for a direction by anyone who might have some experience with this. 

Frank

 

 

 

 

 

Coordinator
Dec 1, 2011 at 2:41 PM
Download the source code for the toolkit and see how I share code the between WPF and Silverlight. The technique is to put the shared code in a SL project, then from the WPF project add linked items to the classes in the SL project that you want to include. In the SL project they are compiled for SL and in the WPF project they are compiled for .NET4.

Cheers,
Tony
Dec 1, 2011 at 3:09 PM

That make a lot more sense than the other first exemple I saw online & tried for myself (they had it backward with the shared code in the WPF project).

Thanks for the answer, much appreciated.

And again, thanks for sharing your framework and all your examples! 

Your project section at Codeplex is the best one & most complete I've seen so far!!  Two thumbs up for that!!!

 

Have a good day,

Frank

 

 

Coordinator
Dec 6, 2011 at 2:08 PM

My pleasure! Also note the use of the compiler directive #if SILVERLIGHT, #else.  This way you can have code for both platforms within the same code file.