Sharing Silverlight and WPF Models with MVVM Light - wpf

I have a Silverlight class library which is a model in my MVVM app. I am using MVVM Light. How easy is it reuse that model in a WPF app and use the MVVM Light framework. The framework has different dlls for WPF and Silverlight so I guess there is incompatability of sorts. I was wondering if anyone could talk me through the options. Cheers, Chris.

The suggested option is to use the Project Linker, this tool synchronizes code over multiple projects, allowing you to maintain a Silverlight and WPF dll with one codebase.

I hope you mean model means data in WPF and Silverlight. If that is the case, you can expose the data using a Service. It can be any service like web service, WCF service or WCF RIA service. Since a service can be multi tenented you can have a Silverlight as well as WPF client accessing the same service.
If you are trying to share the ViewModels between Silverlight and WPF using MVVM light, I would suggest you have a look at the MIX 2011 video of the presentation by the creator of MVVMLight library Laurent Bugnion. This is called Deep Dive MVVM and is a very good session. In short you can share ViewModels between WPF and Silverlight by adding the file from one project to another as a "LINK".
Hope this helps

Related

Is that possible to develop one application in both WPF and Silverlight?

I've already worked with WPF but i don't know anything about SilverLightnow I need to develop an application which can run on both Mac and Windows,so i was thinking to write an WPF Application with MVVM for Windows and run it on Mac Using SilverLight?Is that possible to port from WPF to Silverlight and how much work needs or maybe should I write the application with SilverLight from beginning,even for my Windows users?Which one is better and faster?
a quick answer is Yes..
but lot of things to do. You could share most of XAML view across platform but not all of them.
try to put all business logic into service layer like BAL or middle tier
put presentation logic into ViewModel class library
create separate XAML View (for SL and WPF)
there are several docs about target multi-platform here..
A Cross-platform WPF, Silverlight & WP7 Application at codeproject
Sharing Code Between Silverlight and WPF

WPF VS Silverlight

I had a few questions on WPF & silverlight?
When to use WPF? Some examples on
real time projects where WPF is used
When to use silverlight? some examples of real time projects where silverlight is used
What is the difference between
them?
Can WPF and Silverlight be used together?
How do WPF and silverlight differ from traditional asp.net applications (form based & MVC)???
Does Silverlight use WCF to do it's code behind stuff..like it provides an interface and uses web service to get the code behind?
WPF vs Silverlight will tell you what you want to hear...
WPF is a thick Windows client platform that has access to the full .Net Framework. Silverlight is a browser-based technology that has access to a subset of the .Net Framework
In short I would generally use WPF for form/window applications and use Silverlight for online things. Though these both can be used for either, that is how/when I would use it.
WPF and Silverlight both use XAML, so if you can code in one, you can pick up the other just as easy.
WPF is a client based platform while Silverlight is web based. WPF has the full .NET framework available while Silverlight has a streamlined "smaller" version of the framework.
The nice part is both use the same markup (XAML). Both also can work with the MVVM pattern for easy conversion from client to web app and vice versa.
I would read up a little on the web as these arethe basics of these 2 technologies.
WPF and Silverlight are conceptualy completly different things. They use same technology, but their purpouse is completly different.
WPF is thick client framework, that is supposed to replace WinForms in (I hope) nearest future. It has acces to full .NET framework.
Silverlight is Flash-like technology for rich internet applications and thin clients. It is complementary to standard ASP.NET technology. If you want to increase amount of eye-candy or give user much richer interaction options for your web, this is way to go.
They both use same visual-description technology (XAML) and same principles (DataBinding, Templating, Separation of visuals and code, etc..). But their intended usage is different.

WPF Prism Entity Framework repository

I am building a WPF application using the PRISM guidance, I want to use the Entity Framework 4 for a data repository.
I have previously developed a Silverlight app, using Prism and WCF RIA Services which worked great as all my components are decoupled.
So what is the best way of getting data in my WPF application in a decoupled way.
Thanks for any advise
You might have a look at the BookLibrary sample application of the WPF Application Framework (WAF). It shows how to use the Entity Framework in a WPF MVVM application. However, it's not PRISM.

MVC Frameworks for WPF

Are there any MVC frameworks available for WPF other than Caliburn (which looks awesome btw)?
Both Caliburn and PRISM are very nice. However if you go down the path of MVC you will miss out on the powerful 2 way binding. Consider MVVM, it's a very clean and practical approach for WPF. This is the pattern Microsoft used for their expression blend.
There is also Magellan, a port of ASP.NET MVC for WPF.
There is Composite WPF aka PRISM from Microsoft Pattern & Practices.
http://www.codeplex.com/CompositeWPF
one additional possibility is pureMVC (www.puremvc.org)
it seems well-proven, has good short doc/UML, and the project is responsive, and has been ported to .NET - there exists an WPF demo, it will be published soon but you also can contact the project owner about it.
Regards,
Paul
A new MVC framework that works with practically and .net technology (WebForms, WinForms, WPF, Xamarin Forms) is SimpleMVC by Gateway Programming School. This link gives an overview and example usage.
A short example is to create a controller from SimpleControllerBase that has your business logic. This will depend on the SimpleModelBase implementations you provide. Implementations of ISimpleView are handled through WPF pages and controls. The derived controller only works with the interfaces that extend ISimpleView so that the WPF parts are abstracted away. You then use properties on the view to do two-way data-binding, just like MVVM, but with a proper layered architecture.

Can A winform app be switched to a WPF one if MVC architecture is used?

If we develop a winform app using an MVC architecture, it should not be too hard to change over to WPF at a later date, correct?
Well designed WPF application heavily leverage data-binding. As such, you might consider using classes such as ObservableCollection and others and implement IPropertyNotify when designing your model.
Look up some references to the M-V-VM pattern advocated by Microsoft product groups (e.g., Blend) for more information.
It seems that in Codeplex there is an MVC winform open souce fmwk for developping winforms app
That framework is koossery.MVCwin, located on Codeplex at http://koosserymvcwin.codeplex.com

Resources