Unit Testable WCF Web Services in MVVM and Silverlight 4

In all my previous MVVM in Silverlight 4 posts i was avoiding to address one painful aspect of the Silverlight: calling WCF Web Services.

And it was not without reason. Lets face it, consuming WCF Web Services from your Silverlight application can be pretty hard.

I mean hard to do it in a clean way off course.

Yes we all know how to create a Silverlight enabled WCF Web Service from Visual Studio but things become messy from that point.

First question is how to invoke methods of the web service?

Should we use Add Web Service Reference from the Visual Studio and and get the service proxy generated for us by the IDE?

If you go down that route, its easy to start and you will be invoking web service methods asynchronously in no time, but you will pay the price for that simplicity later, that is for sure.

from Slobodan Pavkov          more here

Simplified MVVM: Silverlight 4 Video Player

Introduction

img7 Simplified MVVM: Silverlight 4 Video Player img24 Simplified MVVM: Silverlight 4 Video Player This project demonstrates an implementation of the MVVM (Model-View-ViewModel) pattern to create a fully “Designable” Silverlight Video Player. This is not to be confused with a “Skinable” Video Player. A Skinable Video Player allows you to change the look and feel of the buttons that control the player. A Designable player allows a Designer to use ANY set of controls to implement the Video Player.

The MVVM pattern allows a programmer to create an application that has absolutely no UI. The programmer only creates a ViewModel and a Model. A designer with no programming ability at all, is then able to start with a blank page and completely create the View (UI) in Microsoft Expression Blend 4 (or higher).

Note: to build the prject you may need to install the Silverlight 3.0 RX Extensions from http://msdn.microsoft.com/en-us/devlabs/ee794896.aspx (they are scheduled to be included in the released version of ASP.NET 4.0).

from Michael Washington         more here

Simple ViewModel Locator for MVVM

I like the MVVM Light Toolkit but I like John Papa’s  idea too.

Make the use of the ViewModel locator more simple.

But back to MVVM … I’ve been exploring the world of View first again. The idea is simple: the View is created, and it creates the ViewModel in the View’s XAML. Very simple to do when you create the ViewModel as a static resource in the View’s XAMl, however it gets a little more complicated when you want to see the ViewModel bind at design time in Cider or Blend. This is important … I wanted to have the View create itself first, then the ViewModel, and have design time data. One option is to use a ViewModel locator  (using the service locator pattern). This is a fine option and is used by MVVM Light Toolkit (a nice light MVVM framework). The thing I did not like was how much maintenance was involve din the ViewModel locator. So out came my “challenge everything I know” trait.

more here from John Papa

What’s new in MVVM Light V3

V3 of the MVVM Light Toolkit was released during MIX10, after quite a long alpha stage. This post lists the new features in MVVM Light V3.

Compatibility

MVVM Light Toolkit V3 can be installed for the following tools and framework versions:

  • Visual Studio 2008 SP1, Expression Blend 3
    • Windows Presentation Foundation 3.5 SP1
    • Silverlight 3
  • Visual Studio 2010 RC, Expression Blend 4 beta
    • Windows Presentation Foundation 3.5 SP1
    • Windows Presentation Foundation 4 RC
    • Silverlight 3
    • Silverlight 4 RC

For more information about installing the MVVM Light Toolkit V3, please visit this page. For cleaning up existing installation, see this page.

from  Laurent Bugnion

more here

The Case for ViewModel

One of the comments I got on my last post on view/view model hookup options was the following:

I’ve been a mvvm fan but actually when I see all the hoops to jump through I wonder at times how effective this is

So I wanted to take a moment to list what I thought compelled me to adopt the ViewModel pattern of client application development (so much so, that I now feel odd writing Silverlight and sometimes even Ajax apps in any other way). Some will be obvious benefits, especially to those already using MVVM in their everyday development, but I want to throw in a couple that are farther out exploratory ideas that I am thinking about. I’d also love to pursue what it means to make view model more mainstream, so if you’ve got ideas on this topic of “Why ViewModel”, I’d love to hear.

ViewModel Pattern

from Nikhil Kothari                more here

Implementing Model-View-ViewModel with the Bing Maps

OK, it is not new but very usefully. MVVM and BingMaps

I’ve (James) been looking at the Bing Maps (Virtual Earth) Silverlight Map Control and thinking about how to use it in a Silverlight application that implements the Model-View-ViewModel pattern. If you’re not familiar with this pattern, check out Shawn Wildermuth’s MSDN Article Model-View-ViewModel in Silverlight 2 Apps.

I’ve created a simple proof of concept application that implements the pattern with two Views: a Map based View and a Data Grid based View. The application displays a map of well known surf spots in the Los Angeles area, along with some basic information about each spot in an accompanying data grid.

image thumb Implementing Model View ViewModel with the Bing Maps

from James            more here

MVVM presentation from NDC2009 on Vimeo

Last year I gave a presentation on the MVVM design pattern at the Norwegian Developer Conference. Most of the presentations from NDC2009 was recorded and made available online, including mine. However, the user experience of the video content on the NDC site isn’t the best. Playing a video requires multiple clicks, and the videos are only available in WMV format.

more here


Learning the M-V-VM pattern for XAML development

If you want to understood  the Model-View-ViewModel
then go to Tim Heuers blog. He will help you. ;-)

“Quick, what’s the most popular thing in XAML development?  Yeah, thought so…MVVM or Model-View-ViewModel.

It’s one of the most popular subjects I hear about when people talk about developing applications with WPF and Silverlight.  However, as much as it is talked about and as much as frameworks are born every day, there isn’t a ton of just simplified ‘here’s how you do it’ information in one place.  I mean, sure there *is* information, but I have to admit I think it is a bit scattered all over. …..”

Silverlight 4 and Behaviors

I was pleasantly surprised to see in the Silverlight 4 feature list that it will be possibly to setup Bindings on DependencyObjects (as opposed to FrameworkElements) in the same way you can with WPF. This greatly affects in my opinion the benefits of Blend Triggers, Actions and Behaviors, being able to bind them to other elements or a ViewModel (if using the MVVM pattern) lets you set up some really cool stuff.
from Nigel Sampson             more here

New MEF Drop (Preview 9) on CodePlex!

from Mike Taulty

I was pretty excited to see that there’s a new drop of MEF up on CodePlex - if you’re a reader here then you’ll know that MEF will ship with Silverlight 4 and with .NET Framework 4.0 ( it’s already in the beta/RC bits in both cases ) and there are versions on CodePlex targeting Silverlight 3 and .NET Framework V3.5 Sp1.

The phrase that I like to use to describe MEF is that it is a;

framework for composing applications out of a set of loosely coupled parts that are discovered and can evolve at run time

that’s not an official “MEF team” definition - it’s just Mike’s view and there’s many places where MEF makes sense such as in building pluggable application architectures and also in implementing patterns like MVVM.

more here

Silverlight 4 and Behaviors

from by Nigel Sampson

I was pleasantly surprised to see in the Silverlight 4 feature list that it will be possibly to setup Bindings on DependencyObjects (as opposed to FrameworkElements) in the same way you can with WPF. This greatly affects in my opinion the benefits of Blend Triggers, Actions and Behaviors, being able to bind them to other elements or a ViewModel (if using the MVVM pattern) lets you set up some really cool stuff.

more here

Applying MVVM in the VS10 XAML designer

from Rockford Lhotka

Visual Studio 2010 includes a new XAML designer, with capabilities roughly comparable to the Windows Forms designer we’ve enjoyed all these many years.

This means you can use drag-and-drop design concepts to get controls from the Toolbox onto the design surface, drag them around, see snaplines and use the Properties window to set properties (including data binding). And the Data Sources window works, so you can drag entire objects or specific properties from a data source (like a CSLA .NET business object) onto the design surface to create a UI control with the data binding all set up.

image thumb Applying MVVM in the VS10 XAML designer

I’m very excited about this designer, as I think the lack of a good designer has been the single biggest roadblock to WPF (and now Silverlight) adoption. While some people are OK with manually typing XAML, I think a lot more people have been (im)patiently waiting for tooling so they don’t have to work at that level. I’m in the latter camp, but I’ve been forcing myself to type XAML for a few years now because the results are so much better than Windows Forms that it has been worth the pain.

more here

Developing Testable Silverlight Applications

from www.testingtv.com

Learn how to keep your customers, management, and quality assurance team happy by building testable Silverlight applications. Explore how the Model-View-ViewModel (MVVM) and Inversion of Control principles can be used with .Net RIA Services to create Silverlight applications with high testability across multiple tiers. Hear guidance from the Silverlight team on how to best use the available testing tools and technologies to take full advantage of your improved application designs to boost quality.
more here

Project Next - Client/browser side technology. Why not Silverlight.

Doing a lot of reading recently trying to understand the directions where the MS client/browser side development is going. I have to deliver a very intensive data-entry application in the next 7 months and that makes me wonder what is the best approach nowadays.

As go-live would be in a year from now I’m able to consider any betas. The options I started with were Silverlight 4.0 versus combination of ASP.NET MVC 2.0 with MvcContrib, jQuery, new Ajax features and probably some Silverlight with ASP.NET MVC host.

Silverlight 4.0 (Beta 1 now) Project Next   Client/browser side technology. Why not Silverlight.

Prism v2 with MVVM would be the guiding frameworks to follow. Although as I understood Prism v2 is more about modular design and not exactly about achieving good MVVM (http://stackoverflow.com/questions/1595409/mef-vs-prism-what-is-the-difference-what-will-be-supported-in-the-future).

more from Stanislav Dvoychenko  here

Rules of MVVM??

As I had a MVVM session at my office, I was re-reading a few articles about MVVM. We have very interesting discussion about MVVM in WPF Disciples User Group as well. You can read that post from here.

Someone in Silverlight Forum (link) posted that ~

“There are currently three main areas of criticism regarding the MVVM pattern. The first is that MVVM currently lacks standardization from Microsoft both in implementation and in toolsets. For example, the community has some lack of clarity about where and whether to implement View logic in the View layer or the ViewModel. Given that the MVVM pattern is still relatively new, and that new tool-sets, walkthroughs, or patterns, such as Onyx, Prism, the Microsoft WPF Toolkit, Crack.net, Caliburn and MVVM Light Toolkit are being released, this problem may be solved over time. Microsoft has announced in discussion boards that the MVVM template pattern will be released in Visual Studio 2010.

The second comes from MVVM creator John Gossman himself, …

more here from Michael Sync