XAML Spy and Universal Apps

Visual Studio 2013 Update 2 introduces the concept of Universal Apps. With the Universal App project types it is now possible to use the Windows Runtime to build apps that can target multiple devices. At this point in time you can create Universal App projects that target both Windows 8.1 and Windows Phone 8.1. Universal App support for XBox has been announced and will be added in the future.

Visual Studio adds a Shared project to your solution when targeting multiple devices. The Shared project contains the assets that will be shared between the projects. The files of the Shared project are automatically merged into the main projects when building the solution. The Shared project itself does not output an assembly.

Enable XAML Spy for Universal Apps

When you select the Manage XAML Spy for Solution... option in the solution context menu, a dialog is shown where you can enable and disable XAML Spy for multiple projects at once. As shown in the screenshot below, the Shared project is disabled.

You do not need to enable XAML Spy for the Shared project. The XAML files in the projects are merged into the main projects and are decorated by XAML Spy automatically. XAML Spy adds metadata to any XAML file it can find, to enable features such as source line info. To learn more about XAML decoration, see the online documentation.

Compiling XAML Spy enabled projects

Consider the following Universal app targeting both Windows and Windows Phone. The Shared project contains the App.xaml and MainPage.xaml files.

With XAML Spy enabled for both Windows and Windows Phone projects, compiling the solution results in the following MSBuild output.

1>------ Rebuild All started: Project: UniversalBlankApp.Windows, Configuration: Debug Any CPU ------
2>------ Rebuild All started: Project: UniversalBlankApp.WindowsPhone, Configuration: Debug Any CPU ------
1>  Added reference to XamlSpy.WinRT451
1>  Decorating App.xaml
1>  Decorating MainPage.xaml
1>  UniversalBlankApp.Windows -> UniversalBlankApp.Windows.exe
2>  Added reference to XamlSpy.WP81
2>  Decorating App.xaml
2>  Decorating MainPage.xaml
2>  UniversalBlankApp.WindowsPhone -> UniversalBlankApp.WindowsPhone.exe
========== Rebuild All: 2 succeeded, 0 failed, 0 skipped ==========

The App.xaml and MainPage.xaml files are merged into the main projects and automatically decorated by XAML Spy. Additionally, XAML Spy adds a reference to the XAML Spy client library specific for the project target. The Windows project references XamlSpy.WinRT451, the Windows Phone project references XamlSpy.WP81. XAML Spy determines the client library by inspecting the project targets.

Conclusion

XAML Spy works great with Universal Apps, just enable XAML Spy for your Windows and Windows Phone projects. There is no need to enable XAML Spy for the Shared project. When the XAML files of the shared project are merged into the main Windows and Windows Phone projects, the files are automatically decorated by XAML Spy.

Related links



Latest News

RSS feed

Subscribe to the RSS feed and receive the latest XAML Spy news updates in your favorite RSS reader.

Subscribe

 

Twitter

XAML Spy is on twitter! Join the conversation and follow @xamlspy.