Tales from the Trenches – Building a Real-World Silverlight Line of Business Application

There's rarely a boring day working in the world of software development. Part of the fun associated with being a developer is that change is guaranteed and the more you learn about a particular technology the more you realize there's always a different or better way to perform a task.

I've had the opportunity to work on several different real-world Silverlight Line of Business (LOB) applications over the past few years and wanted to put together a list of some of the key things I've learned as well as key problems I've encountered and resolved. There are several different topics I could cover related to "lessons learned" (some of them were more painful than others) but I'll keep it to 5 items for this post and cover additional lessons learned in the future. The topics discussed were put together for a TechEd talk:

  1. Pick a Pattern and Stick To It
  2. Data Binding and Nested Controls
  3. Notify Users of Successes (and failures)
  4. Get an Agent – A Service Agent
  5. Extend Existing Controls

The first topic covered relates to architecture best practices and how the MVVM pattern can save you time in the long run. When I was first introduced to MVVM I thought it was a lot of work for very little payoff. I've since learned (the hard way in some cases) that my initial impressions were dead wrong and that my criticisms of the pattern were generally caused by doing things the wrong way.

In addition to MVVM pros the slides and sample app below also jump into data binding tricks in nested control scenarios and discuss how animations and media can be used to enhance LOB applications in subtle ways. Finally, a discussion of creating a re-usable service agent to interact with backend services is discussed as well as how existing controls make good candidates for customization.

I tried to keep the samples simple while still covering the topics as much as possible so if you’re new to Silverlight you should definitely be able to follow along with a little study and practice. I’d recommend starting with the SilverlightDemos.View project, moving to the SilverlightDemos.ViewModels project and then going to the SilverlightDemos.ServiceAgents project. All of the backend “Model” code can be found in the SilverlightDemos.Web project. Custom controls used in the app can be found in the SivlerlightDemos.Controls project.

image_418B5BFB1_47FBF5721_75802FD51_32D30289[1]

 

Sample Code and Slides

comments powered by Disqus

6 Comments

  • Dan,

    t.GetEvent(action + Completed).AddEventHandler(proxy, callback) causes the callback to be called multiple times. In the vm, I have the following test code that will be executed when a login button gets click:

    proxy.CallService((s, e) =>
    {
    if (e.Result == null)
    {
    this.IsLoginFailed = true;
    }
    else
    {
    SystemUser user = e.Result;
    MessageBox.Show(String.Format("Welcome: {0} {1}", user.FirstName, user.LastName), "Test", MessageBoxButton.OK);
    }
    }, this.UserName, this.Password);

    Since I am just showing a msg box, the view is still active after you close the msgbox and the next time you click the login button, the callback gets executed twice and so on...

    What I did was to write a detach callback whenever a callback gets completed. I was wondering if you have a better solution for this.

    Thank you,
    Ian at Recovery Innovations.

  • Ian,

    Good to hear from you. I'm not seeing this behavior since the proxy object isn't being re-used between calls. If the object isn't created each time (which would certainly be an option if you want the same object re-used) then you'd definitely have to detach it. If you're not re-using the proxy and seeing things called more than once send me a sample project if possible and I'll take a look.

    Dan

  • Hi Dan,

    Great post! I am trying to port your success animation to WPF but am unable (there appears to be no CompositeTransform). Do you have any code that uses the same concept, but in WPF?

  • Dave,

    Glad you found the code useful. CompositeTransform was added in Silverlight 4 and I've actually never tried it in WPF. However, if you're not seeing it as available you could still do the standard RenderTransform, add a TransformGroup and then add the different transforms inside of the TransformGroup. CompositeTransform just simplifies getting to some of the transform object properties. I don't have anything specifically for WPF unfortunately.

    Dan

  • Hi Dan,
    Just watched your talk at tech ed, excellent stuff!

    I noticed you said you were using PLINQO in your “Jobs” project, I’m considering using it in a new project and was wondering if you were using the plinqo generated entities in the Silverlight client as the model or if you’ve implemented an alternate Presentation Model?

    Thanks

  • Matt,

    Glad you found the talk useful. As far as PLINQO, I'm returning the PLINQO generated entities from the server through a WCF service but Silverlight is only using the entities generated with the WCF service proxy. They have some stuff in them that won't work with Silverlight libraries so I can't share types directly unfortunately. But...you could certainly modify the template to change that behavior. I've been happy with the defaults though (only made minor modifications to the templates).

    Dan

Comments have been disabled for this content.