Give it a try here:


It’s no secret that I use for my blog.  I have been too busy to rewrite the whole thing but I did have time to test out writing a WebApi to expose my blog data and buid out a tiny AngularJs version of my blog. 

Basically the HTML for the site becomes very small.  Angular provides all the data binding framework.  I even tested out building a jQuery component.

Next, I am going to build out a cleaner version with a more out of the box Bootstrap design and use Backbone for the data binding framework.  I am just working through which I like better so I am using my blog as the test bed.

This is pretty easy.  Basically you can send any property values to the Window object that is being created to hold your root view.  Simply create a Dictionary<string, object> with the property name as the key.  Pass that dictionary to the DisplayRootViewFor<>() method and viola!

I have an application that uses the WPF frame for navigation.  The frame markup looks like this:

This Frame tag is located in my ShellView.xaml file and this takes the place of a ContentPlaceholder.  In order to navigate to another page I simply call ActivateItem( viewModelInstance ) from my ShellViewModel.  Because the ShellViewModel orchestrates the page loads I created a simple ChangeViewMessage class to throw via the EventAggregator.  My ShellViewModel handles this message and passes the viewModel instance to the ActivateItem method.  Caliburn Micro takes care of everything else.

Here is an example of the ShellViewModel loading my initial page/view in the constructor.

You can see that my first view (SelectServersView via the ViewModel) is loaded there.

In order to make Caliburn Micro work you have to patch one method to be ‘Frame Aware’.

In the View.cs class of the Caliburn Micro source in the Caliburn.Micro.WPF project change the SetContentPropertyCore method to look like the one below.  This allows you to use a Frame.




Just posted the code that I am using for an iOS project of mine that handles all the Web Api calls.

Example of use:

WebApiClient.Post<ServiceResponse<User>>(string.Format ({0}Auth/Login?emailAddress={1}&password={2}
  , AppDelegate.Current.ApiBase, email.Value, password.Value), , )
.ContinueWith ( (t) =>

            this.InvokeOnMainThread(() => { loadingView.Hide (); });
            var result = t.Result;
            if (result != null && result.IsSuccess && result.Payload != null)
               this.InvokeOnMainThread(() => 
                  AppDelegate.Current.UserInfo = result.Payload;
                this.InvokeOnMainThread(() => {
                    new UIAlertView(Invalid login, Invalid username or password., null, OK).Show();

I wrote a simple generic method for making POST calls to MVC4 WebApi for use on Windows Phone 8 (But you can use it elsewhere).  The idea is simple: Create one set of generic methods that will take a generic TResultType, an Api Uri, and optionally some data to post and return back a strongly typed response object.

Usage is simple:

This allows you to simply use await to make your MVC4 WebApi calls and get back strongly typed objects.  The Post code uses Newtonsoft Json library to deserialize the response string as an object.

I will package this up as a simple GIT project when I have time and create a nuget package so that everyone can use this simply.

First off, I did not author this from scratch.  Instead, I added some functionality to this class that WindowsPhoneGeek published. I wanted to add CanExecute() and Execute() methods that take no parameter.   Most of the commands I use in my MVVM apps tend to be based on the state of the ViewModel anyway and thus I do not need the parameters.

Here is the DelegateCommand.cs class and the cmds snippet that lets you quickly add a command to any ViewModel.


Command code would look like the following:

The code for the DelegateCommand.cs looks like this:

This is a pretty rookie mistake with .NET 4.5 and the new async / await operators.  While searching for the answer I found a lot of noise and no valuable answers so I thought I would notate the solution on my blog.

The short answer is that any method that uses await must itself be marked with async.

Take this code for example:

Error    2    The ‘await’ operator can only be used within an async method. Consider marking this method with the ‘async’ modifier and changing its return type to ‘Task’. 

This problem has been solved and answered many different ways but none of the answers seem to propose a complete basic or step by step solution.  This article is my attempt to consolidate the answer into one concise how to article.

Executive Summary

For those of you that want the answers quickly, here are the steps necessary to properly use WebGet methods in a WCF Service:

  1. Use the WebGet attribute and specify a UriTemplate.
  2. Use the webBinding binding type in your web.config.
  3. Create an endpoint behavior that specifies webHttp in your web.config.
  4. Reference the endpoint behavior in the service endpoint configuration section.
  5. Set the binding in the service endpoint configuration to webHttpBinding (or to the name of the binding configuration that specifies webHttpBinding).

How-To / Step by Step

In this section we will go through the process of creating a simple service with Visual Studio 2010 that performs a simple WebGet operation.

Create a new WCF Service Application project.


I am going to leave the default Service1 class and interface names intact for simplicity.

Open the IService1.cs code file and change it so that it looks like this:

Note the WebGet attribute in the interface definition.  Now we are going to modify the Service1.cs file to implement the AddNumbers method.

This implements the method.

Compile the project and make sure it builds. Next we are going to update the web.config file so this actually works.

In Visual Studio click Tools | WCF Service Configuration Editor, Load the web.config file for this new project.


You will see the WCF Config Editor.

Now we are going to create a Service Endpoint and an Endpoint Behavior.

Click the Services configuration node and click Create a New Service.

Click Browse to find the service type.  You are going to navigate to the DLL that implements your WCF service (hint, it should be in your /bin folder).


After clicking Open you will be allowed to choose the class that implements your service.  Click it and then click Open.


After clicking Open you will click Next.  This will bring you to the service contract screen.  This screen is asking you what the interface is that describes your service.  Typically this will be automatically detected and filled out for you.


Click Next.


Choose HTTP and click Next.


Choose Basic Web Services interoperability and click Next.

For the Endpoint Address enter / and click Next then on the summary page click Finish.


You will now have a service configured in your Web.config file.


Now we will create an endpoint behavior.  Expand Advanced, Right Click on Endpoint Behaviors and choose New Endpoint Behavior.


Click Add, Choose webHttp and click Add.


The new behavior configuration screen will now look like this:


Change the Binding to webHttpBinding and select the NewBehavior0 behavior configuration.


Click Save and exit from the WCF Service Configuration tool.

Now you should be able to start your WCP project and navigate to the web method in your browser and see a result like below.


Note that the URL contains your .svc file and then the UriTemplate property of the WebGet attribute kicks in. 

Source code for this project:

I am working on a project where I need to resize a bunch of raster images from miscellaneous sizes to fit within a certain frame.  More specifically, I need a bunch of icons for an iPhone application and I need them to fit within a 64px by 64px frame.  I found a bunch of Photo Shop scripts, some console apps, and a few spamware solutions.  I figured half an hour and I would have one that works well.  I was right.


So here is how the app works:

Drag and drop the graphics files you wish to resize into the application.  The files will show in the list view area.  Next, enter the Max Height and Max Width values and then click the Resize button.

The application will write the resized file next to your original with _MaxHeightxMaxWidth appended to the filename.  Original files are not modified in any way during this process. 

So if you found this blog post in hopes that you would find a quick and simple image resizer for free, here is the link to the binaries: 

A little about the application source code.  The application is a .NET 4.0 WPF application that follows the M-V-VM (MVVM) design pattern.  Since there is drag and drop support in the application there is a little code behind to support this.  The rest of the application follow the MVVM pattern.

There is a tiny image resizer class in the project that you are free to use.  This is located in the DevSQL.Imaging assembly. 

The source code can be found below.

So I decided to jump in to serial communication.  Why not?  I have a ublox LEA-5H-0-009 GPS Receiver and a GS407 break out board from I connected the red (3.3v) and the black (gnd) from the GPS to the netduino.  There is a TXO and RXI pin and a GPIO pin on the GPS break out board (BOB).  I admit, I had to google a lot.. I mean a LOT to figure this one out.  Eventually I found a great article from with 99.9999% of the solution. 15.35.28

I learned a lot about serial communication from reading Bob’s article.  In summary, what I learned is that I can use D0 and D1 on my netduino as a serial port COM1.  D0 is COM1 IN or RX and D1 is COM1 OUT or TX.  The last piece of the puzzle was the GPIO pin on the GPS.  Clueless me had no idea what to do with the GPIO pin.  After reading his blog, it seems that is used to turn on and off the power.

Here are a few better views of the connections.  Ignore the IC chip and the three axis sensor on the project board. 15.35.38 15.35.28

When I first connected the device I was getting nothing from it because the TX and RX were flipped.  Then, I started getting bytes from the serial port but they were poorly formatted and I could not convert them to UTF.  This caused errors when using the System.Text.UTF8Encoding.UTF8.GetChars(buffer); code.  As it turns out the baud rate needed to be 9600 and I had it at 4800.  After that fix I was set and I was getting NEMA messages.

It does not look like it is picking up a signal yet but that is my next step.  Get the messages decoded and get the device to lock on a few satellites.

Here is the code I used which I got from Bob’s post and tweaked a bit as I was running into issues decoding the bytes because of the baud rate issue.