XAML Spy API and Roslyn REPL

Wednesday, December 9, 2015

XAML Spy 3 includes the XAML Spy API, a library for querying and automating apps. The XAML Spy API works great with interactive REPLs such as the Roslyn powered REPL available in Visual Studio 2015 Update 1. With just a few lines of code you get access to a wealth of information of any connected app.

The following animation demonstrates the power of XAML Spy API in an interactive environment.

The following features of the XAML Spy API are demonstrated;

  • Explore and search visuals in the visual tree
  • Use XPath expressions to select visuals
  • The rich type system
  • Reading and writing object member values
  • Invoke methods on remote objects using automation patterns

The above animation demonstrates the XAML Spy API using a connected Windows 10 UWP app. The API works equally well for other supported platforms, such as Android and iOS.

Try this at home

Want to give the XAML Spy API a spin? Make sure you have XAML Spy 3 installed, and for working with the Roslyn powered REPL, you need Visual Studio 2015 Update 1. The REPL is availabe via View > Other Windows > C# Interactive.

Bootstrap the XAML Spy API by loading the XamlSpy.csx script in the REPL (located at [XamlSpyInstallFolder]\Scripts\XamlSpy.csx). The main entrypoint for the XAML Spy is the variable client of type ClientService.

Note: in XAML Spy 3 Preview 1, the main entrypoint variable is named spy, not client

Comments, questions? Contact us.