Visual Studio template for Caliburn.Micro Windows Phone apps

I have been building Windows Phone apps using the Caliburn.Micro framework for some time now. Setting up a new project takes some time and can be easily automated, so I decided to create a Visual Studio template for Windows Phone apps build with Caliburn.Micro.

The templates can be downloaded from the Visual Studio Extensions gallery and used to build Windows Phone 8 and Windows Phone 8.1 Silverlight apps. It contains the basic setup with Caliburn Micro and Fody, with a sample view and viewmodel.

The source code is available on GitHub, so if you want to modify it to best suit your needs, feel free to do it.

Detecting tablets and smartphones in ASP.NET

I recently worked on an ASP.NET application that needed to detect if users were coming from tablets or smartphones. The project used data from to do this detection, but the result were not really good. We needed a better solution, so I came up with using WURFL.

WURFL, the Wireless Universal Resource FiLe, is a Device Description Repository (DDR), i.e. a software component that maps HTTP Request headers to the profile of the HTTP client (Desktop, Mobile Device, Tablet, etc.) that issued the request. Adding WURFL to your ASP.NET application is easy thanks to the WURFL_Official_API Nuget package. The Nuget package also contains definition file, so you just need to update the Nuget package once in a while to get your definition file up to date.

After installing the Nuget package, you need to setup WURLF in your Global.asax file

I recommend setting the match mode to accuracy instead of speed, to get the best results. Using the WURFL library is also quite easy, just pass the user agent string and get the properties you want.

TvTime: track your favorite TV shows on Windows Phone

We have just had released a new app called TvTime. TvTime is a simple and beautiful app for tracking your favorite TV Shows. Simply add a find the TV Shows you like, add them to the list and get detailed information about actors, air times and episodes. If you decide to track unwatched episodes, you will always know what you have already seen. So get TvTime now so you never miss your favorite TV Show!

Main features

  • clean and simple design
  • thousands of TV Shows to choose
  • tracking unwatched episodes
  • live tile
  • show and episodes details

You can download the app for free here.

What to put on the about screen of your Windows Phone app

The about screen of a Windows Phone app is usually the most overlooked part of the app. Sure, the users usually visit it only once, after installing the app, if ever, but it is a part of your Windows Phone app that you could put to a good use.

If you have ever taken a DVLUP challenge you may have noticed, that they recommend you place a text describing your app on the about screen. I really do not agree with this. If users install your app, they know what the app does and if they cannot figure it out, then your UI is a failure and the about screen will not save you.

After some trial and error I came up with a standardized about screen I now use in all my apps. It is a pivot with two tabs; About and More apps.

The About tab is the most important. It shows the version of the app, this is important when users report problems, information about the author and the designer of the app with Twitter contacts and buttons to send feedback via email and rate the app in the Windows Phone Store. Providing a feedback mechanism is really important, the users will write you about an issue they have with the app instead of just giving you a bad review in the Windows Phone Store.

The screenshot shows the About page from my latest app TvTime. You can easily get the app version from the manifest using the ManifestHelper from the Kulman.WP8 Nuget package.

You should know that submitting an app is just a beginning, you then have to answer to user feedback, provide bug fixes, etc. In my case, the Feedback button launches an EmailComposeTask with filled in recipient and subject so the users just write what is on their minds and send it to me. I always answer each and every one of those feedback emails.

I use the second tab, More apps, as a form of cross-promotion.

If the users like your app, they may also like your other apps so why not make it easier for them to get them. I have a simple XML file with names, links and icons of my apps hosted on a webserver that the app downloads and displays, of course removing itself from the list.

To sum it all up, do not underestimate your about screen, use it to provide your users with a feedback mechanism. You will make your apps better.

Experience with being featured in the Red Stripe Deal promotion on Windows Phone

I was offered to to take part in the Red Stripe Deal promotion on Windows Phone with my Shopping List Simple app from 21st August to 28th August.

In this promotion, your app has to cost less than half of the normal price. The app normally costs 1.29 USD in most countries and 0.99 USD in Czech Republic, Slovakia and Russia to boost the sales. The minimum price in Windows Phone Store is 0.99 USD so the app had to be made free for the promotion. So I filled in the form saying that I want my app to be free in all the countries during the promotion. When the time of the promotion came, the price was set to free in all the countries except Czech Republic, Slovakia and Russia. First day, first problem.


The promotion was a success with about 25 000 (free) downloads.

Another positive effect was that I got contacted by users offering translations of the app and acquired Turkish and Ukrainian translations.


As soon as the Red Stripe Deal promotion ended, I submitted a new version of the app with the two new translations … and the problems started. The users started to report that the update fails to install, usually with 80004005 as the error code. If you try to google this code, you find out it is too generic, ranging from Zune to XBOX and that no helpful info can be found about this error code.

I contacted Microsoft support and they, as usual, were not helpful at all. They replied that everything is ok with the app, the error code indicates WiFi issues, so it is a problem on the users’ end and that they should contact the support.

There was another problem. Users who got the app for free thanks to the Red Stripe Deal and uninstalled it, had to pay for when reinstalling. This really sucks and I am sure that in the past, when you got an app while it was free you never had to pay for it in the future. It looks like things changed, because I got this from Microsoft:

In regards to users having to pay for the app if they re-install it, this works as designed. If the app was free when it was downloaded and the price changes between the time the consumer re-installs they will be charged whatever the “New” price is.

Looks like this was an misinformation from Microsoft, they corrected it:

Let me correct myself. The only time I see the app being changed is when I use a device that is not tied to the live Id that I purchased it from. If I buy an app under and then login to another device using a different live Id I will have to pay for the app. If I use the same live Id I own the app and will not have to pay even if the price of the app has changed. You will also see a change for the app if I have loaded the app on the maximum number of devices allowed.

The other error code, that the users were experiencing, was c101a7d1. Microsoft support sent my a link to a discussion suggesting users uninstall the app and install it again, meaning they would have to pay for it now (according to users who tried it), maybe all 25 000 of them! This is going to be a real blow to the reviews and ratings! And some people even thing I did it intentionally to make money!


So what did the Red Stripe Deal bring me? Many new users, but many of them angry about the update problems and need to buy the app when they uninstall it and it also made some of the “old” users angry about the update problem. Was it worth it?

Update: Problem still not solved.

I told the users to contact Microsoft support as Microsoft support told me, but they report the support cannot / will not help them. The support guy I am in contact with did not want to believe this, so I had to ask one user for a screenshot of Microsoft support telling him they cannot help and send it to him. Did not help either.

Automatic ViewModels and Services registration for (not only) Caliburn.Micro

My MVVM framework of choice, Caliburn.Micro, provides a simple Dependency Injection container, where you have to register all your ViewModels and Services. This is done in the Bootstraper’s Configure method and may look like this:

where you typically register your ViewModels as per request and services as singletons.

Of course this is done just once, but having to register a ViewModel each time you create a new one can be a nuisance, especially in a large project.

There is a better way that uses reflection. First, you need to create attributes that will represent registration as per request and a s singleton:

Iterating over all the non-abstract classes in your assemblies using reflection is quite easy, the tricky part is deciding when to register a class as “itself” and when to register it for an interface it implements. My rule of thumbs is that if the class implements exactly one interface, it is one of my services and I register it for that interface, otherwise I register it as itself (ViewModels descendant from Screen implement circa 5 interfaces).

The final registration code looks different for WinRT (Windows 8, Windows 8.1, Windows Phone 8.1 XAML)

and for “classic” .NET (Windows Phone 8)

because of reflection differences in WinRT. Do not forget to add the PerRequest or Singleton attribute to your classes to make it work.

Converting between pixels, meters and map coordinates in Windows Phone

In my current project I needed to solve one quite interesting problem. Imagine you have a map with some pins representing points of interest. If the user taps on a pin, a label with the place title is shown like on this image (that is not from the real project, obviously).


The client had an interesting requirement. When the user taps the pin and the label is shown, they wanted the label to be centered on the map (basically move the map so the label appears in the middle of the map).

In Windows Phone you can only center the map to a GeoCoordinate. If you center the map to the tapped pin’s coordinate, it is not quite right, you also need to move it by half the width of the label to the left (and half of the height down). So the solution consists of two steps

  1. Convert half of the label width in pixels to meters for a given zoom level (pixels -> meters conversion)
  2. Subtract the result from the pin’s coordinate (meters -> degrees conversion)

(and the same for height)

The map component in Windows Phone 8 and 8.1 has quite a nice documentation, so the first step requires some math but is not so difficult.

I created two helper functions to take care of this first conversion

The second conversion is more difficult, especially if you want to do it really well. I found a simple solution that works quite ok when you are not right at the poles and used it. The helper function looks like this.

Now you just need to put it all together and you are done.

Ignoring certificate errors in Windows Phone 8.1

Connecting to servers with self-signed, expired or otherwise problematic certificates has always been a problem in Windows Phone. There is no way to ignore certificate errors in Windows Phone 7 and Windows Phone 8, not even using the new Portable HTTP Client Libraries. If you are dealing with a self-signed certificate on the server, you have to somehow get it (may not always be possible) and install it on the device or in the emulator (for emulator every time you close and start it again). Ignoring certificate errors would be a much more comfortable approach. Of course, only do it in development with dev servers, not in production.

In Windows Phone 8.1 there are strangely two HttpClient classes, one in System.Net.Http and another in Windows.Web.Http. Normally you would go with the one in System.Net.Http because you are probably using it thanks to the mentioned Portable HTTP Client Libraries on every other platform. You are out of luck in Windows Phone 8.1 XAML, if you want to ignore certificate errors, you have to use the one from Windows.Web.Http, because only this one accepts an IHttpFilter as an argument.

Using the IHttpFilter, you can easily ignore certificate errors

but you have to get used to doing all the request in a different way, the Windows.Web.Http.HttpClient way that differs from the System.Net.Http.HttpClient way.

Making your Windows Phone Silverlight 8.1 app a Share Contract target

Windows Phone 8.1 introduced many interesting new thing, the one I personally like the best as a developer is the Share Contract. The Share Contract allows your apps to share data using an unified and easy way and also to receive data from other apps. This functionality is important for my Pock8 app, which is a Pocket client. By making Pock8 app a Share Contract target, the app can receive links from other apps, more importantly from the built-in webrowser (IE). This makes the app even more easy to use and valuable.

Pock8 as Share Contract target

The problem is that all the documentation I found and also the sample app are for Windows Runtime. Pock8 is a Silverligt app and I have no intentions to rewrite it to Windows Runtime.

I had to make some digging and I finally found the solution in a build video called Contracts and Pickers: Building Apps that Work Together on Windows.

First you have to add the Share Contract ability to the new manifest file (Package.appxmanifest, the Declarations tab). If you want to receive links, Choose weblink as data format. This step is the same for Windows Runtime and for Silverlight apps, but all the other steps differ.

You can determine if your application was launched normally or as a Share Contract target in the application Launching event. If you cast the LaunchingEventArgs to ShareLaunchingEventArgs and the result is not null, your application was launched as a Share Contract target. The video recommend creating an internal property of type ShareOperation in App.xaml.cs and saving the data from ShareLaunchingEventArgs there:

(I use Caliburn.Micro so I do it in the OnLaunch method of the Bootstrapper)

The next thing to do is to show a separate sharing page instead of the page you would normally show when your app starts. Create a AssociationUriMapper like you would do when registering for a protocol and simply check the ShareOperation property in App.xaml.cs:

If you use Caliburn.Micro as I do, do not forget to register the AssociationUriMapper in the Boostrappers CreatePhoneApplicationFrame method:

Crawling mobile app stores with F#

Some time ago I needed a way to programatically search the Apple AppStore and Google Play Store to get some info about apps for a project. I decided to write an F# script for that task and later added support for Windows Phone Store.


I wanted the script to be easily usable from outside of F# so first I created a type for the app.

I also needed a helper function to download data from the web. I used a classic WebClient with user agent set to Chrome, because the Windows Phone Store API requires a user agent header

Apple AppStore

Searching in Apple AppStore is easy, because Apple provides a simple search API that returns JSON. Thanks to the JsonProvider from FSharp.Data, the code is really simple

Just downloading the JSON transforming the data to our type.

Google Play Store

Searching in Google Play Store is a bit more of a challenge. There is no API I could found so I had to parse the html returned from the web version of Google Play Store. The web can change at any time so I need to be aware of this fact and fix the method if it happens.

Another problem with parsing the web is that there is no way to return search result for a specific country like for Apple AppStore. The web always shows results according to your IP address.

Windows Phone Store

There is no official API for searching the Windows Phone Store but I was given a tip obtained after sniffing the traffic from a Windows Phone, so I did not have to parse the web. The code is as simple as for Apple AppStore thanks to XmlProvider.


Using F# is fun and processing data is really simple thanks to type provides. You can find it whole code at

© 2014 Coding Journal

Theme by Anders NorenUp ↑