Silverlight Sample Application – Part 4

In this series blog post I’m continuing to talk about the sample Silverlight application that was used in the Ottawa and Toronto code camps this year.

You can get the source to the application on CodePlex.

The purpose of the application (other than to show people how to get started with Silverlight application development), was to be an IT event information application.  The second ‘page’ of the application shows information on the tracks and sessions available.

Here it is showing session information for the Ottawa IT Day.

20100613 sessions

This data was published using an OData-based service which is included with the source code.

Silverlight 4 includes networking classes specifically for OData.  We can use the Add Service Reference feature to add proxy classes which in this case include EventDataContainer.

20100613 sessions code

Silverlight includes LINQ to OData client classes so we can create a LINQ query on the container client proxy class which will be translated (when enumerated) using the magic of IQueryable-based LINQ implementations into an OData URI.  We create a DataServiceCollection based on the Track proxy class and assign it to the ListBox so that results can be shown once this DataServiceCollection is populated.  We then set up a completion handler on the collection and then load the collection asynchronously which causes the LINQ query to be converted.

Once the query completes, we’ll have a set of Track objects in the collection that will appear bound in the UI.  For each Track object we then asynchronously load the Session information underneath each Track.

DataServiceCollection is great because it includes the INotifyCollectionChanged implementation that works with the Silverlight binding system to show the session information under each track as the data loads in.

Check out the code to see the bindings in the XAML.

Check out other series blog posts for more information about this sample application.