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 automated approach described in the quick start is not sufficient. Setting up a manual connection is easy, reference a NuGet package, and add a tiny code snippet to your app.

Keep in mind that you need to remove XAML Spy from your app when you are ready to deploy your app. XAML Spy is a develop/test tool, end-users do not have XAML Spy installed. Also, the various app stores will refuse apps that have XAML Spy enabled.

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).

Step 1: Add a NuGet reference to XamlSpyLibs

Step 2: Modify your app's code as per the platform-specific instructions below

Android

Enabling XAML Spy for Android, requires adding or modifying an Android.App.Application instance. The default Android templates do not include an Application instance. When no Application exists, add the following C# class to your project;

using Android.App;
using Android.Runtime;
using System;

namespace YOURNAMESPACE
{
[Application]
public class _App : Application
{
public _App(IntPtr javaReference, JniHandleOwnership transfer)
: base(javaReference, transfer)
{
}

public override void OnCreate()
{
base.OnCreate();
}
}
}

Locate the OnCreate method in your existing or new Application instance and add the following code snippet;

var service = FirstFloor.XamlSpy.Services.XamlSpyService.Current;
service.Connect("[address]", [port],"[password]";

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

iOS

Locate the main entry point of the app. The entry point is a static void Main(string[]) method usually found in the source file Main.cs. Add the following code snippet to the start of the method, make sure the code is added before the main application loop is started using UIApplication.Main invocation.

var service = FirstFloor.XamlSpy.Services.XamlSpyService.Current;
service.Connect("[address]", [port],"[password]";

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

Silverlight and Windows Phone

Open the App.xaml.cs code-behind file and add the following code to the constructor;

var service = FirstFloor.XamlSpy.Services.XamlSpyService.Current;
service.Connect("[address]", [port],"[password]";

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

Windows Store and UWP

Open the App.xaml.cs code-behind file, and locate the OnLaunched(LaunchActivatedEventArgs) method. Add the following code to the method:

var service = FirstFloor.XamlSpy.Services.XamlSpyService.Current;
service.Connect("[address]", [port],"[password]";

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

WPF

Open the App.xaml.cs code-behind file, and locate or add the overridable OnStartup(StartupEventArgs) method. Add the following code to the method:

var service = FirstFloor.XamlSpy.Services.XamlSpyService.Current;
service.Connect("[address]", [port],"[password]";

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