The perhaps most obvious difference between Windows Phone and Windows 8 is that XAML is no longer a part of .NET in Windows 8. The reason for it being so obvious is that all references to System.Windows breaks the build. Simply put – XAML now resides in Windows Runtime instead of .NET.
The problem is quite easy to fix. In this post we will discuss why XAML has moved and how you deal with it.
This post is a part in a series – you can find the full index here.
In order to understand why they have made the trouble to move XAML I think that we first need to look at all languages and technologies that can be used building Windows 8 metro applications.
So – you can use any of these to build metro applications and they all got in common that they use Windows Runtime to access native functionality in Windows 8. Since all got Windows Runtime in common it could be a good idea to place common functionality there as well, for example how to define the UI. So by moving XAML (and HTML 5) into Windows Runtime it is possible for both C++ and VB.NET/C# to use the same XAML library. Something that was not possible as long as XAML was a part of .NET and was compiled to IL code.
So what does this mean for us? Very little it turns out. Basically all XAML that we are used to in .NET are available in Windows Runtime. All that we really need to do is to switch namespace.
As I mentioned earlier – there is no big deal to correct the compilation errors that occurs when moving all of our code to Windows 8. Here is a list showing the namespaces in .NET and Windows Runtime.
As you can see it is quite obvious what needs to be done (feel free to optimize by using Ctrl + Shift + F,H).
That is all.
This is, of course, one of the simpler fixes that you need to do (and that you cannot escape) while converting to Windows 8. Look at it as a warm up for the issues further ahead.