Silverlight Design Architecture - silverlight

Is there a good Silverlight Design Architecture?

There is Prism it was originally designed for WPF but there is now a Silverlight release.

Also there is Caliburn, an "Application Framework for Silverlight and WPF".

You could take a look at Rocky Lhotka's CSLA.NET for Silverlight - CslaLight

Soon, Microsoft will be releasing a new version of Prism (though unlike the earlier answer), the Silverlight version of Prism is just a proof of concept. The PnP team hope to have a full release in the next couple of months. The prevailing story today is to use the same MVVM pattern that WPF has had success with (searching for Silverlight and MVVM will yield a lot of info).

Related

MVP or MVVM framework for both WPF and .NET CF 3.5 development

I am creating a draft architecture outline for a disconnected client-server platform, that involves multiple different client types. I need to support: web clients, desktop workstations and mobile devices (WM 6.x now and Android later).
I am searching for a MVP or MVVM based framework that would let me to reuse as much of the code and architecture as possible between clients, while:
using WPF for desktop development
using .NET CF 3.5 for Windows Mobile development
This framework does not obviously need to support Android, however I am considering Mono for Android to develop the Android client (for easier maintenance of the whole platform), so portability would have been an added asset.
So far I ruled out:
Prism (does not support WM based mobile devices - Windows Phone 7 only)
MVC# (does not support WPF)
I would appreciate any hints that would aid in researching the subject further.
These MVVM Frameworks work with Windows Phone 7:
Caliburn Micro
MVVM Light (it doesn't advertise it, but I've been to a demo where it was used on WP7)
ReactiveUI (Uses the Reactive Extensions for .NET)
My personal favorite is ReactiveUI, but if you've never used the Reactive Extensions it can be a brain burner at first.
As for UI Composition (you mentioned Prism), there aren't a lot of options, mostly due to reflection restrictions on the phone. I have seen an article where someone got basic MEF working on the phone and MEF is probably all most people need in this situation. You can check out that article here.
Hope this helps.
In my opinion, this would be a custom Framework with a mix of UI Processes for different client types. The business logic or entities can definitely be reused to suit the needs of the view.
I did the same research and I concluded the following (which I did not implement yet):
There aren't any open source MVVM frameworks that support .NETCF. You
can only find MVC or MVP, but not MVVM.
Suggestion: get the source code of an Open Source MVVM framework that supports the Full/Desktop .NET, and see if you can adapt it(so that it recompiles) to the .NETCF. I found the following two, which also support the other platforms that you mentioned:
MVVM FX for Windows Forms and Visual WebGUI - Home
MugenMvvmToolkit
Other than that, I don't see any other way of doing this.
HTH,
MVVM wouldn't make much sense in Windows Mobile + .NETCF since you don't have INotifyPropertyChanged and implementing Model-View-Presenter in WPF or any INotifiyPropertyChanged supported framework wouldn't be as effective as Model-View-ViewModel
You can share assets between the full and compact framework by moving most of the business logic into a seperate class library (or several) that target the .NETCF. You can reference a .NETCF library from a full framework project, but not the other way around.
Check out this very good article by Daniel Moth describing how to share assets between the compact and full framework:
http://msdn.microsoft.com/msdnmag/issues/07/07/ShareCode/default.aspx

Windows Phone 7 Silverlight MVVM (and other) frameworks

What are the available mvvm frameworks for WP7 out there today? Which one(s) would you recommend and why? Are there other useful frameworks one should consider when starting WP7 silverlight development.
Thanks for posting your experiences so far.
Cheers,
Phil
Have a look at this MVVM framework comparer. You can filter the frameworks by supported platform (WPF, SL, Windows Phone)
I've had good experiences with MVVM Light Toolkit, using the Silverlight Unit Test Framework for unit testing.
Admittedly I don't have any experience of any other MVVM toolkits, but it seems to work. I'm not using it extensively, and the ViewModelLocator pattern hasn't been terribly helpful for me - but I suspect it depends on exactly what you're doing with it.

Good way for experience WPF developer to learn Silverlight

I'm a developer with WPF experiences, my next project will use Silverlight. I have read some articles on the internet (almost all msdn and silverlight.net) and I think that they aren't much different. Anyway, I still have questions that I'm not sure.
What is different between WPF 4 and Silverlight 4? (I found an article on msdn but its based on .NET framework 3.5)
Are there any resources for learning Silverlight that are good for experience WPF developer?
Do I need a book on Silverlight?
I personally really like the course posted here:
http://channel9.msdn.com/learn/courses/Silverlight4/
I don't know what you intend to develop using Silverlight. But it's a good start if you like to develop business applications using Silverlight.
WPF has hardware-accelerated full faceted 3D support
WPF has direct access to the full .NET framework
WPF can take full advantage of the hardware on the system.
Silverlight allows you to create a single app that works across browsers, operating systems.
You can use Silverlight for Windows Phone 7 development
For Books, I would recommend Silverlight Recipes and Microsoft Silverlight 4 Data and Services Cookbook.

A good Silverlight 3.0 reference application, with source?

Having never written a production quality Silverlight app, I am looking to find a quality open source reference application for Silverlight 3.0 (Silverlight 4.0 is no good as I have VS2008) to help learn Silverlight.
Ideally I'd like to see:
a line of business application, in the client-server tradition.
SQL Server back end
no use of 3rd party libraries like PRISM or CSLA as I would like to see how the core Silverlight technologies work.
I realise there are plenty of open source projects on Codeplex, but struggled to find any classic line of business apps there.
This is a really good one:
http://timecard.codeplex.com/
The following does use Prism, but you can learn a lot from it. It even shows localization:
http://happynet.codeplex.com/
In all honesty, get yourself upgraded to VS 2010. If you are serious about becoming a professional in Silverlight development, version 4 has the most bang-for-your-buck.
Not all the newer technologies are supported for Silverlight 3 and all the latest cool tutorials and project examples tend to be in VS2010/SL4.
You also should not ignore patterns like MVVM and libraries like Prism & MEF as they are rapidly becoming commonplace for Silverlight projects. There is more danger of you getting into Win-forms-style bad habits if you use a Win-forms style approach to Silverlight at first.
Here is a simple explanation of MVVM for Silverlight:
http://openlightgroup.net/Blog/tabid/58/EntryId/89/Silverlight-View-Model-Style-An-Overly-Simplified-Explanation.aspx
These videos are a good introduction to creating/understanding Prism-based projects, specifically for Silverlight:
http://channel9.msdn.com/posts/mtaulty/Prism--Silverlight-Part-1-Taking-Sketched-Code-Towards-Unity/
It includes him building an Outlook-style application using prism (with full source provided).
The codeplex project, full source and documents etc, for Prism and soon MEF is here:
http://compositewpf.codeplex.com/wikipage?title=Getting%20Started&referringTitle=Home
Prism was created by Microsoft and will soon have a final release of version 4 (including MEF).

Silverlight 2 UI pattern

I have to build small (for now) admin app in Silverlight2, and would like to use some pattern for binding UI with my BL/DAL.
I found view-model-viewmodel and mvp/mvc patterns, where first one (V/M/VM) is specially suited for WPF apps, because it uses rich capabilities of WPF data-binding options. What do you suggest? Can you write simple example of V/M/VM for SL2?
Nikhil Kothari has a great set of examples (with code) on M-V-VM in Silverlight as well as a framework built with some very nice extra features. You should definitely check them out.
M-V-VM in Silverlight
The Patterns & Practices group at Microsoft has put together some guidance around doing WPF and Silverlight applications.
You might want to look at CSLA.NET for Silverlight. I've heard good things about it but haven't gotten around to try it yet myself.
CSLA .NET for Silverlight is a subset
of CSLA .NET targeted at the
Silverlight platform. CSLA .NET for
Silverlight offers nearly all the
benefits of CSLA .NET on Silverlight,
including data binding, validation,
business rules, authorization, n-level
undo and persistence.
The result is that CSLA .NET for
Silverlight enables the creation of a
rich object-oriented business layer
running on the Silverlight client,
that can transparently communicate
with CSLA .NET objects running on the
web and application servers.
Silverlight has also very powerful data-binding, so there is no problem with that.
The missing piece in Silverlight that affects more to the Model-View-ViewModel pattern is that it doesn’t implements commands like WPF. Here is an article by Josh Smith that reproduces the command pattern of WPF in Silverlight.
Shawn Wildermuth of Wildermuth.com wrote an article about the MV-VM Pattern, check it out, here is the link of the article "Model-View-ViewModel In Silverlight 2 Apps"
Norwegian developer Gjøran had a very nice presentation/demo at MSDN Live about writing business apps in WPF. Really it was about using Presentation Model with Silverlight/WPF. Have a look at the source code from this article on his blog (sorry, the slides are in Norwegian only). Presentation Model + silverlight 2 rocks!!!

Resources