Converting to Windows 8 from Windows Phone | XAML has a new home (4 of 12)

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.

Why move it?

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.

  • HTML 5 and Javascript
  • XAML and C++
  • XAML and VB.NET/C#

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.

Solution

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.

System.Windows
System.Windows.Automation
System.Windows.Automation.Peers
System.Windows.Automation.Provider
System.Windows.Automation.Text
System.Windows.Controls
System.Windows.Controls.Primitives
System.Windows.Data
System.Windows.Documents
System.Windows.Input
System.Windows.Interop
System.Windows.Markup
System.Windows.Media
System.Windows.Media.Animation
System.Windows.Media.Imaging
System.Windows.Media.Media3D
System.Windows.Navigation
System.Windows.Printing
System.Windows.Resources
System.Windows.Shapes
Windows.UI.Xaml
Windows.UI.Xaml.Automation
Windows.UI.Xaml.Automation.Peers
Windows.UI.Xaml.Automation.Provider
Windows.UI.Xaml.Automation.Text
Windows.UI.Xaml.Controls
Windows.UI.Xaml.Controls.Primitives
Windows.UI.Xaml.Data
Windows.UI.Xaml.Documents
Windows.UI.Xaml.Input
Windows.UI.Xaml.Interop
Windows.UI.Xaml.Markup
Windows.UI.Xaml.Media
Windows.UI.Xaml.Media.Animation
Windows.UI.Xaml.Media.Imaging
Windows.UI.Xaml.Media.Media3D
Windows.UI.Xaml.Navigation
Windows.UI.Xaml.Printing
Windows.UI.Xaml.Resources
Windows.UI.Xaml.Shapes

 

As you can see it is quite obvious what needs to be done (feel free to optimize by using Ctrl + Shift + F,H).

Change namespace

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.

This Post Has 3 Comments

Leave a Reply

Close Menu