Service Driven Apps with WCF and Silverlight 2

    2008-09-MSDN

    The latest edition of my Data Points column in MSDN Magazine is now online and has my Service Driven Apps with WCF and Silverlight 2 article.

    Its a long title … but the article is exactly what it says. The article explains how to build a multi tiered application using WCF to pass custom entities between a middle tier and a Silverlight 2 client application. In the article are discussions on dealing with cross domain policies, entity serialization, WCF configuration for Silverlight 2, data binding, implementing CRUD in the app, and notifications.

    Enjoy!

     

    DotNetKicks Image
    #1 Neil Barnwell on 8.29.2008 at 4:45 AM

    Hi John,

    I read your article with some interest. I've no experience of Silverlight or WCF just yet, but am planning to shortly.

    One question I have is on saving values. I don't normally do databinding (I've always preferred the old-fashioned approach, though I'm trying to change) so I was wondering how the values updated might be saved to the database in this case? I might have skipped this part somehow but didn't see it explicitly saved.

    Sorry for the stupid question. Keep up the good work.

    Neil.



    #2 Dew Drop - August 29, 2008 | Alvin Ashcraft's Morning Dew on 8.29.2008 at 9:03 AM

    Pingback from Dew Drop - August 29, 2008 | Alvin Ashcraft's Morning Dew



    #3 John Papa on 8.29.2008 at 11:52 AM

    Neil ... Glad you like it. The databinding in this example uses XAML based databinding (the style used in both WPF and Silverlight). When the object list (i.e. Product) comes back from the WCF service, the list is set to the DataContext of the ListBox. This provides the ListBox with immediate access to read and write to the list. The template for the ListBox binds to individual properties of each product, which is what displays them. The ListBox tempalte uses OneWay binding since it only needs to display values.

    The details section allows the user to save data, so it uses the binding mode of TwoWay. This means that the changes typed into a TextBox are automatically sent to the bound object (the Product instance). So when a user presses the Save button, the Product instance is grabbed from the DataContext and it is sent to the DB via WCF and the middle tier.

    Basically, with the XAML databinding you do not need to push the values into the fields nor pull them back out ... it handles it for you.

    I hope that helps!



    #4 Robert on 9.19.2008 at 5:44 PM

    I've been trying to get your sample code to work in VS08. The Silverlight GUI shows ok in the browser but there isn't any data displayed. Frankly I'm too new at this to even firgure out where the NorthWind DB should be but I can't find it in the sample project. Which file in the project defines the connection to the DB and where is that DB?

    Thanks.



    #5 Updated Sep 2008 MSDN Article Code for Silverlight 2 RC0 on 10.08.2008 at 4:00 PM

    I wrote my Data Points article for the September 2008 issue of MSDN Magazine using Silverlight 2 Beta 2. Since then the RC0 bits have been released, which broke my code for the article. I’ve had several requests for the updated code … and now that my



    #6 Updated Sep 2008 MSDN Article Code for Silverlight 2 RC0 on 11.18.2008 at 9:48 AM

    I wrote my Data Points article for the September 2008 issue of MSDN Magazine using Silverlight 2 Beta 2. Since then the RC0 bits have been released, which broke my code for the article. I’ve had several requests for the updated code … and



    Leave a Comment