15. September 2011 23:41
See intro blogpost here.
For the most part your XAML ports right over to WinRT. However an important change is how you register namespaces from your assemblies.
Here's how you do this in Silverlight and WPF for an assembly "MyAssembly.dll" and namespace MyAssembly.MyNamespace:
And similar for namespaces in the same assembly as where the XAML file lives (ie MyAssembly):
In WinRT, you only declare the namespace (never the assembly) and instead use "using" instead of "clr-namespace":
Unfortunately we don't have #if-def statements in XAML so you can just use compiler directives on your XAML and make it work on both platforms. So until we get that (or Microsoft reverts the above change) you are going to have to duplicate and maintain two sets of XAML. :-(
I actually do like this change, and this is probably how it should always have been, but it's a change that cause a lot of pain for developers trying to reuse their existing codebase. The benefit doesn't seem to pain (from what I understand the Windows team simply didn't like it said "clr" in there, plus they don't have the exact same concepts down in the runtime so the assembly part was left out.)