Hello Windows 8 XNA-ish

Yes you read that right. You can really get a flavor of XNA on that snazzy new Windows 8 installation of yours.

Anything you build using this can work as Modern UI app. I know for many of us, like the crew at Three Red Cubes, this revelation put a smile across our faces.

Before you think I am bluffing, much of what I am about to detail has been covered by the original posts. Also, there is a Channel9 post about it.

Here is a rundown of my experience and the broad strokes of the steps.


The answer to the owes of XNA developers comes in the form of MonoGame which is an open source implementation of Microsoft XNA 4. MonoGame allows XNA-style development for plenty of platforms but that’s not the focus.

The development of MonoGame for Windows 8 has been a little slow so the hackers at SickHeadGames came to the rescue.

Now it is possible to migrate existing XNA games without having to dive through SharpDX.

(Kind of Long) Setup

a. Getting into Github

Github account and the client are free. Also, One click installs are awesome!

b. MonoGame Source Code

1. Run Git Shell.
2. Change directory (cd) to where you want to store your code
3. Copy and paste this to the shell and hit enter:

git clone https://github.com/SickheadGames/MonoGame && cd MonoGame && git submodule init && git submodule update

to start pulling the code.

c. Visual Studio Template

If you browse to C:\Users\[you]\Documents\GitHub\MonoGame\ProjectTemplates\VisualStudio11.MonoGame.2.5\VS11MGWindowsMetroTemplate you’ll find a whole bunch of files that you can zip up and copy over to C:\Users\[you]\Documents\Visual Studio 2012\Templates\ProjectTemplates\Visual C#. This will create a Visual Studio 2012 project template once you restart Visual Studio.

d. Reference MonoGame

Once you start a solution using that new template we just created, right click on your solution in the Solution Explorer and add the MonoGame Framework Windows 8 Project from C:\Users\[you]\Documents\GitHub\MonoGame\MonoGame.Framework\MonoGame.Framework.Windows8.sln.

Now, add a reference to the MonoGame Framework in your game project by right clicking on references, select Add Reference. Under Projects choose the MonoGame Framework project (check the box!) and click OK.

e. Hit F5

Make sure you select the game project to be the startup project and compile and run the project.
You should be greeted with the good-old cornflower blue that XNA programmers know and love.

f. Content Pipeline

You may have noticed the absence of that good old content project. At this time, MonoGame does not have an implementation of the Content Pipeline and Visual Studio 2012 does not have native support for XNA development therefore we need a workaround until which is in about a month at the time of writing:

1. Head over to Aaron Stebner’s blog post and (possibly) install XNA Game Studio or Windows Phone on Windows 8.
2. Open up Visual Studio 2010 and create a XNA project that will come with the content project.
3. Import all your resources and build the project which will output xnb files to C:\Users\[you]\Documents\Visual Studio 2010\Projects\[project name]\[project name]\[project name]\bin\x86\Debug\Content.
4. Copy these files to your MonoGame project’s Content folder: C:\Users\[you]\Documents\Visual Studio 2012\Projects\[project name]\[project name]\bin\Debug\AppX\Content.

Now, you can use the ContentManager object to load game assets during runtime. Just like the XNA we know.


All of this came into light, once again, from Bob Familiar’s blog posts. And it is only possible because of the hard work of the MonoGame project and SickHeadGames.

Q & A

So, is XNA dead?
I don’t think so. It has been reincarnated in Windows 8.

Will there be a Windows 8 XNA Game Studio release from Microsoft?
We don’t know yet, but you never know.

Is MonoGame the only solution?
No, SharpDX is just an awesome a solution.

For now though, here’s to having XNA back on Windows 8.


Building Laaalallaaa Share

My tally for Windows Phone 7 applications isn’t too high. Not compared to some of my friends at Three Red Cubes. In my defense though, I’ve been working on several MVC projects that are pure fun to work with. But to close the gap, I got down and dirty and wrote Laaalallaaa Share (♫share).

The application is really simple but it uses a very interesting .Net namespace Microsoft.Xna.Framework.Media and some classes from Microsoft.Phone.Tasks.


This static class exposes a number of methods and properties to access the media player (duh!) and the library.

For example I used the properties in MediaPlayer.Queue.ActiveSong to find the details of the current song being played. MediaPlayer.State holds the status of the media player, use it to find the state of the player.

This class also exposes a number of events such as ActiveSongChanged or MediaStateChanged that lets the application know if the current song has changed or if the song has stopped/started playing. Handy stuff.


Launchers and Choosers in the Windows Phone world give us developers access to a number of operating system and user functionalities.

The MediaPlayerLauncher is used to “start the media player and play the media file you specify.” But you don’t necessarily have to play a file, you can just take the user to the music player, like I did. Read more about this class.


As of Windows Phone 7 Mango (Windows Phone OS 7.1), this class exists in the Microsoft.Phone.Tasks namespace. This class launches “a dialog that enables the user to share a status message on the social networks of their choice.”

By setting the Status property and calling Show you could get to the People Hub’s “Post a Message” page and let the user post away. Read more about how to use this task.

There you are, three nifty little classes that do really cool things that I hope you’ll use in your next application. Say… when you sign up for The Developer Movement and win a bunch of expensive cool gadets or Imagine Cup and win a lot of money!

Serialization and Isolated Storage in WP7

Reading XML in and out from the provided Isolated Storage is important and quite simple, as the following code snippets illustrate. I have the methods constrained to a generic so that I can use this across all the WP7 applications that I am writing.

To write, the Isolated Storage allocated is called on by IsolatedStorageFile.GetUserStoreForApplication() where objects, XMLized by XmlSerializer serializer are written by the XmlWriter writer. The code is pretty telling, I think, so I’ll spare you the explanation.

public static void Write<T>(T obj, string fileName)
    XmlWriterSettings writerSettings =
            new XmlWriterSettings
                Indent = true,
                IndentChars = "\t"

        var store = IsolatedStorageFile.GetUserStoreForApplication();
        IsolatedStorageFileStream stream = store.OpenFile(fileName, FileMode.Create);

        XmlSerializer serializer = new XmlSerializer(typeof(T));

        using (XmlWriter xmlWriter = XmlWriter.Create(stream, writerSettings))
            serializer.Serialize(xmlWriter, obj);

    catch (Exception emAll)
        throw emAll;

To read XMLized objects from storage, the following function is sufficient and pretty self explanatory. Again, the function is constrained to generic objects so that you can go crazy on what types you want to use it with.

public static T Read<T>(string fileName)
         var store = IsolatedStorageFile.GetUserStoreForApplication();
         IsolatedStorageFileStream stream = store.OpenFile(fileName, FileMode.Open);

         XmlSerializer serializer = new XmlSerializer(typeof(T));
         return (T)serializer.Deserialize(stream);
    catch (Exception emAll)
        throw emAll;

Of course, you will have to modify Exception handling to suit your needs, these are only generalized samples. Also, the code can be improved, so write back with improvements that you might have come up with.

Windows Phone 7 Obsession

I’ve been working on a several Windows Phone 7 (WP7) applications. The development tools are a delight and amazing to use. The tools are available here. And when development and testing is so easy with Visual Studio 2010 and Windows Phone Emulator, you can tell why I am obsessed with it.

Among the applications I am working on is a game called Sudoku3D. The team is great fun to work with and I’ve had a lot of learning opportunities and adventures there. We are mostly using XNA Game Studio 4 there, it’s an amazing framework, together with the power of C# 3.0 and Kit Kat (I like Kit Kat, quite a bit), it’s one hell of a ride!

Here’s a short video of the game running on a WP7 device:

In the coming weeks, I’ll post code snippets and thoughts on developing for Windows Phone 7.

The Idea

An idea has spawned from my reading of Practices of an Agile Developer. I have been inspired to share what I learn by reading this very well written piece. I have decided that I will share my experiences as I go on the journey of learning and applying a programming language.

I have vague thoughts on which language and framework to dive in to, and the project I will develop. The details of which I will be sharing in my next post, by which time I hope to have clearer thoughts.