Consuming an ADO.NET Data Service from Silverlight

When developing Silverlight line of business (LOB) applications we often need to get at some data from a database. There are various ways to do so. One option that is easy to get started with with is creating an ADO.NET Entity Data Model (EDM) and exposing that entity model using an ADO.NET Data Service.   Getting started The first thing we need to create is an ASP.NET Web Application. This is basically going to act as a container for our Data Service and our Silverlight LOB application. As you can see below I named the Web Application SLDataService. Next we … Continue reading Consuming an ADO.NET Data Service from Silverlight

Unit testing in Silverlight part 3

Part 1 Part 2 Part 3 Part 4 This post continues on my previous two post on using the Microsoft Silverlight Unit Test Framework. You can find part 1 here and part 2 here. In the second blog post I showed how to create a wrapper around the WebClient class, the TestableWebClient, so we can actually test code doing asynchronous web access. The part I didn’t really explain was the unit test itself. The unit test code looked likes this: [TestClass] public class FlickrDownloadTest : SilverlightTest { [TestMethod] [Asynchronous] public void Test1() { FlickrRequest request = new FlickrRequest(typeof(MockTestableWebClient)); request.PhotoSearchByUser("97044050@N00", (photo) … Continue reading Unit testing in Silverlight part 3

Data validation – Silverlight versus WPF

When I am creating business applications validating the data in business objects, and displaying any errors, is always a big deal. Even though WPF and Silverlight both use XAML and support data binding the default way to display errors is quite different. Now I am focusing on validation in the business object here even though WPF has additional capabilities of validating input in the XAML using ValidationRules. While there might be some good reason to validate data directly in the UI in some cases I find it a requirement to validate data inside a business object so the validation is … Continue reading Data validation – Silverlight versus WPF

WrapPanel in ListBox revisited

Last week logged about using a WrapPanel in a listBox and demonstrated how to get the content to wrap around, read about it here. Turns out the XAML can be even easier. In the previous post I used a ControlTemplate with a Grid to stop the WrapPanel from just expanding horizontally. Turns out there us an even easier way to do so by disabling the horizontal scrollbar using the ListBox ScrollViewer. The following XAML will do the trick just fine: <UserControl xmlns:controls="clr-namespace:Microsoft.Windows.Controls;assembly=Microsoft.Windows.Controls" x:Class="SilverlightApplication4.Page" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="400" Height="300"> <Grid x:Name="LayoutRoot" Background="White"> <ListBox x:Name="DemoList" ScrollViewer.HorizontalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <controls:WrapPanel /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemTemplate> … Continue reading WrapPanel in ListBox revisited

Unit testing in Silverlight part 2

Part 1 Part 2 Part 3 Part 4 In my previous post I described the basic setup of unit testing in Silverlight, you can read all about it here. The basics where very nice but lots of code we write in Silverlight has to do with networking and in Silverlight that means asynchronous code, something that is always hard to test! Because, just I like using Flickr, lets download some pictures and see what it takes to make that testable. Below is the very simple application we need to unit test, basically a list of pictures from my Flickr photo … Continue reading Unit testing in Silverlight part 2

Unit testing and Windows Workflow Foundation

A while a go I wrote some posts about unit testing Windows Workflow foundation Activities, you can find the posts here and here. Fortunately I am not the only one who thinks unit testing is important as you can find various other blog posts about it like this one from Ron Jacobs. But Cliff Simpkins has taken this one step further and just blogged about a new MSDN virtual lab “Using Test-First Development with WF”! Excellent work and I recommend doing the lab, I know I did! And while you are at it, there are a  number of other interesting … Continue reading Unit testing and Windows Workflow Foundation

Updated SQL Server Compact Workflow Persistence Service

Yesterday I uploaded a new version of the SQL Server Compact Workflow Persistence Service to code.msdn.com. No major changes this time just two new features to get it more in line with the standard SqlWorkflowPersistenceService. I added a GetAllWorkflows() function that returns all persisted workflow’s in the database. I added a LoadExpiredTimerWorkflowIds() function that will return a list of workflow instanceId’s of all workflow’s with an expired timer. Both new functions should help make the SqlCeWorkflowPersistenceService even more like the out of the box SqlWorkflowPersistenceService. And as before it is completely free [:)]. You can download the source code for … Continue reading Updated SQL Server Compact Workflow Persistence Service

PDC session download

Want to download and watch all PDC content? Then there are a couple of ways to get at them. The official way if to go through the session agenda at the conference site. See https://sessions.microsoftpdc.com/public/timeline.aspx. You see all sessions but it takes a bit of work. Another nice way is through Channel 9 by using the following feed: http://channel9.msdn.com/posts/pdc2008/RSS/?tag=videos. But the best as far as I am concerned is using the list compiled by Greg Duncan. Check this list http://coolthingoftheday.blogspot.com/2008/10/pdc2008-quick-video-link-list.html. And it even has the Visual Basic source code used to generate the list [:)] Enjoy the videos! [f1][f2]

Using the ReplicatorActivity in Parallel mode

I have heard quite a few times that the ReplicatorActivity can only be use in parallel mode with a custom activity. The reason being that you need an extra property to store the current child data. When the ReplicatorActivity works in sequential mode the following code works just fine: private void codeActivity1_ExecuteCode(object sender, EventArgs e) { int value = (int)replicatorActivity1.CurrentChildData[replicatorActivity1.CurrentIndex]; Console.WriteLine(“Loop value = {0}”, value); } However when run in parallel the current index always point to the last item so this doesn’t work. As an aside I think this is a bug as it results in hard to find … Continue reading Using the ReplicatorActivity in Parallel mode

Using collections of custom objects in a workflow

Last week during my Chalk & Talk session at the SDC one of the attendees was having problems with workflow persistence and collections of custom objects. Now I never got to see his code so I am not sure what the problem was but maybe this simple sample will convince him that this should work. So we need a simple type, I decided to keep thing really simple and use the following: using System; namespace WorkflowConsoleApplication1 { [Serializable] public class Person { public string Name { get; set; } } } And we need a simple workflow like this. The … Continue reading Using collections of custom objects in a workflow