Would you still use Prism with SL4, even when Silverlight 4 already supports commanding, e.g. MVVM concept?
Are there features in Prism which can be used and improve design of Silverlight 4 application?
Modules - to structure the application (with an option of dynamically loading modules when needed
RegionManager - to deal with assembling UI (layout) from components from different independent modules
EventAggregator - to deal with cross-module communication (e.g. loosely coupled communication)
On a general note, sticking to the Prism pattern forces an additional level of structure on your Silverlight development. This is especially of benefit to dev teams, more than individuals, as that work can be cleanly partitioned.
The latest Prism 4 went to beta on August 2nd and now adds MEF support (Managed Extensibility Framework) to the other features PL mentions.
MEF is great for building a plug-in based framework. As an example of what it can do the Visual Studio IDE itself uses MEF to implement pretty much everything as a plug-in. Now you can do the same sort of dynamic plugins in Silverlight!
We are currently doing Silverlight Prism development with the previous 2.2. release, but will move over to Prism 4 as soon as it is out of Beta.
Related
I’m looking for solution on architecting modular application model in WPF. For now I was using Devexpress POCO MVVM for architecting my WPF apps but is lack of modular extensibility and I’m looking something to work well with my current design and allow to build application composed with modules. My expectations are:
Modules are placed in remote location
Framework can download latest version when application starts (or demand module)
Application should load only subset of all modules basing on permissions of currently logged user
Framework allow integration with GUI – allowing to load list of modules and put graphical representation of module in some part of my application
Library is live and not closed project
I’m thinking about PRISM but this framework always looked little complex and heavy but maybe it was wrong impression. Another library is MEF but I don’t know if it fits my expectations.
Can I ask of some suggestion for modern library which will be good for my needs?
PRISM is a large library but is made of many optional parts making it easy to adopt just the parts you need (its not all or nothing).
Specifically it does do modularisation, with on demand load, and it does do UI composition from modules.
Its also open source.
Versions are valuable for desktop apps (WPF), Universal apps (Desktop app, tablet, phone and possibly iOS and Android via Xamarin - but I'm not sure about that!) so there should be a PRISM for your chosen platforms!
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
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).
Are you using any framework (like Prism or Unity)? What are your experiences with them and are they mature enough to use in production apps?
I would like to create a complete list of all frameworks:
Prism (Guidance, MVVM)
Unity (DI/IoC)
Enterprise Library 5.0 Silverlight Integration Pack (Validation, Logging, Exception Handling, Caching, Interception, flexible config)
Ninject (DI/IoC)
.NET RIA Services (Data)
MEF (Extensibility)
MVVM Light Toolkit (UI Patterns)
Caliburn (UI Patterns)
Silverlight Extensions (Controls/UI Patterns)
Silverlight Toolkit (Controls)
Silverlight Contrib (Controls)
Silverlight Unit Test Framework (Unit Test)
nRoute Framework (Application Flow)
Clog (Logging)
Rhino Mocks (Mocking)
Farseer Physics Engine
IronRuby and IronPython (Dynamic languages in SL)
DeepEarth (Mapping)
.NET Image Tools (Image manipulation)
Kit3D (Graphics)
Update:
I've added a few to the list. I try to keep the list up-to-date with information from other sources.
Farseer Physics Engine : An easy to use 2D physics engine designed for Microsoft’s Silverlight platform. The Farseer Physics Engine focuses on simplicity, useful features, and enabling the creation of fun, dynamic games.
IronRuby and IronPython in Silverlight : The dynamic languages and Silverlight integration let you write browser applications with dynamic languages, like Ruby and Python. Please visit IronRuby or IronPython's websites' for using them in Silverlight.
DeepEarth: An open source, standards oriented Silverlight mapping framework. It provides a rich framework for integrating and visualising spatial layers, services and data.
Silverlight Contrib : Silverlight Contrib is a collection of Silverlight Controls and API enhancements, and productivity tools built for and by the Silverlight developer community.
.NET Image Tools : ImageTools for Silverlight is a library, which provides additional functionality for loading, saving and manipulation images from different sources and with different formats.
Kit3D : A 3D C# graphics engine for Microsoft Silverlight.
There are also:
Silverlight Toolkit
Ninject for Silverlight
I've been using Ninject for a little while now and it's my favorite DI/IoC framework.
Also, note that SilverlightContrib has merged with SilverlightExtensions a while ago. I'm kind of afraid though to see no updates since then.
Just today I found Gestalt which looks interesting. I'm not sure if it's a 'framework'.
Also added the Silverlight Integration Pack for Enterprise Library 5.0 from Microsoft patterns & practices, the same team that brought you Unity and Prism. Supports data caching (in-memory and isolated storage), logging (client and remote service), validation, exception handling and interception with flexibel configuration options (via external config, attributes or fluent interface).
Is it possible to convert an existing WPF Application to SilverLight automatically/with minimal effort?
I would argue that you CAN port Silverlight to WPF with minimal effort. I spent 2 hours porting and application I spent 3 weeks writing. I would argue that those 2 hours spent would categorize as minimal effort.
Sure, you need to create a new project, add the files to the new project and tweak them.
Since Silverlight is a subset of WPF its allot easier to go from Silverlight to WPF than the other way around.
For business logic and non-UI code your code should port almost straight across. I had some minor issues around authentication, as Silverlight 2 will pick up any authentication information in the browser, while in WPF you have to role your own login screen and manage cookies etc.
For the XAML it will port straight across if you don't style your controls. If you style your controls the use of the Visual State Manager, currently missing in WPF, will make things a little trickier. You can either re-style your controls in WPF using Triggers, or you can use the VSM implementation for WPF done by John Gossman. Microsoft have announced that they will add the VSM to WPF to make the two frameworks more compatible.
The perhaps most important reuse tough, is skills and experience. Since the two platforms are so similar you will be able to reuse all your skills in WPF.
I recently did a blog post about the Dive Log sample application and how I ported it from Silverlight 2 to WPF. Might give you some idea of the process.
Not really. I have found some articles regarding the multi-targeting option for WPF and Silverlight at the same time. At this moment, if you are not using PRISM, it is quite a challenge to target both of them, fortunately achievable.
What do you need to have in mind is that Silverlight uses a smaller (thus more limited) library than WPF.
In response to the comments:
Actually, there is already support for silverlight in PRISM (v2). The idea of PRISM is to provide guidance to developing applications not only using WPF but using Silverlight also - Prism V2 formally was known as Composite Application Guidance for WPF and Silverlight.
By using PRISM for silverlight capabilities, it would give you the warranty that your code would work on both platforms with minimal changes, if none (except maybe the different project types for visual studio).
But of course, if you already started developing your application, you would need to change your code to use PRISM.
Will and Bogdan's answers are correct. The keyword here is "minimal".
Rob Eisenberg has a list of differences here (though this was pre-RTW).
List of Differences in WPF & Silverlight
No. Silverlight runs in its own cut-down version of the CLR. It also is WPF-like, not WPF. You'll have to do a fair amount of work to convert it.
Times have changed. Check out Portable Class Libraries, now supported in .NET 4.0. You can build assemblies that can be used on different supported platforms: WP7, Silverlight WPF and even XBOX applications.
Here is a thread about this:
http://silverlight.net/forums/t/3898.aspx