How to connect manually

XAML Spy 3 | XAML Spy 2

This guide describes how to manually connect your app to XAML Spy. Setting up a manual connection is useful when the Visual Studio integration feature of XAML Spy is not sufficient. Setting up a manual connection requires referencing a XamlSpy client library, and adding a couple of lines of code to your app.

Instructions

Step 1: Open your XAML project in Visual Studio

Step 2: Right click the project references in the Solution Explorer and select Add Reference...

Step 3: Select the Browse tab and locate the XamlSpy client library in the XAML Spy installation folder (default: C:\Program Files (x86)\First Floor Software\XAML Spy\Libraries). Client libraries exist for various platforms and versions, be sure to select the correct library for your project or compilation errors will occur. Use the following table to select the correct library.

PlatformVersionClient library
Silverlight 5 Silverlight\XamlSpy.SL5.dll
Windows Phone 7.* WindowsPhone\XamlSpy.WP7.dll
Windows Phone 8 WindowsPhone\XamlSpy.WP8.dll
Windows Phone 8.1 (Silverlight) WindowsPhone\XamlSpy.WP81SL.dll
Windows Phone 8.1 (Windows Runtime) WindowsPhone\XamlSpy.WP81.dll
Windows 8 WinRT\XamlSpy.WinRT45.dll
Windows 8.1 WinRT\XamlSpy.WinRT451.dll
Windows 10 WinRT\XamlSpy.WinRT451.UAP.dll
WPF 4.* WPF\XamlSpy.WPF4.dll

Step 4: Open the App.xaml code-behind file (default: App.xaml.cs) and continue the instructions specific to Silverlight and WindowsPhone, Windows Store or WPF.

Note: the actual remote address, port and password settings, required in the next steps, are found in the XAML Spy Service settings (in XAML Spy navigate to settings > xaml spy service).

Silverlight and Windows Phone

The following instructions apply to Silverlight and Windows Phone apps. Add the following code to the constructor:

var service = new FirstFloor.XamlSpy.XamlSpyService {
RemoteAddress = "[address]",
RemotePort = [port],
Password = "[password]" };
this.ApplicationLifetimeObjects.Add(service);

Compile and run your app, the app will now connect to XAML Spy.

Alternatively you can specify the XamlSpyService in XAML instead of in code for Silverlight and Windows Phone apps.

Step 1: register the XAML Spy namespace by adding the following prefix to the root element. Select the one valid for your app

<!-- silverlight -->
xmlns:spy="http://firstfloorsoftware.com/XamlSpy"
<!-- windows phone 7-->
xmlns:spy="clr-namespace:FirstFloor.XamlSpy;assembly=XamlSpy.WP7"
<!-- windows phone 8 -->
xmlns:spy="clr-namespace:FirstFloor.XamlSpy;assembly=XamlSpy.WP8"

Step 2: Add the XamlSpyService to the ApplicationLifetimeObjects

<Application.ApplicationLifetimeObjects>
<spy:XamlSpyService
RemoteAddress="[address]"
RemotePort="[port]"
Password="[password]" />
</Application.ApplicationLifetimeObjects>

Windows Store

The following instructions apply to Windows Store apps only. Declare a global variable of type XamlSpyService

private FirstFloor.XamlSpy.XamlSpyService service;

Instantiate the service in the constructor, where the 'this' parameter references the current Application instance.

this.service = new FirstFloor.XamlSpy.XamlSpyService(this) {
RemoteAddress = "[address]",
RemotePort = [port],
Password = "[password]"

Locate or add the overridable OnWindowCreated method and start the service:

protected override void OnWindowCreated(WindowCreatedEventArgs args)
{
base.OnWindowCreated(args);
this.service.StartService();
}

Compile and run your app, the app will now connect to XAML Spy.

Note: when connecting to a XAML Spy service using a public facing IP address (non localhost), you'll need to enable the capability privateNetworkClientServer in your app's manifest. If the capability is not specified, an access denied error will occur.

WPF

The following instruction apply to WPF apps only. Declare a global variable of type XamlSpyService

private FirstFloor.XamlSpy.XamlSpyService service;

Locate or add the OnStartup override method and add the following code snippet:

protected override void OnStartup(StartupEventArgs e)
{
base.OnStartup(e);
this.service = new FirstFloor.XamlSpy.XamlSpyService {
RemoteAddress = "[address]",
RemotePort = [port],
Password = "[password]"
}
}

Compile and run your app, the app will now connect to XAML Spy.