Instrument Xamarin.Forms

You can now instrument Xamarin.Forms elements using AppDynamics.Agent.Forms. To add the NuGet package Xamarin.Forms, see Instrument Xamarin Applications.

Page Tracking

Using Xamarin.Forms, you can track page usage and see the how your users interacts with your app in a session timeline.

To track pages, you must call TrackPage from the constructor on each page you want to monitor.

JSON
public partial class MyPage : ContentPage
{
public MyPage()
{
InitializeComponent();
AppDynamics.Agent.Forms.PageTracker.TrackPage(this);
}
}

Track UI Elements

You can track user interactions with these Ul elements:

  • Buttons
  • Entries
  • ListViews

To instrument a UI element:

  1. Attach a property to your views:

    CODE
    appd:UiInstrumentation.IsInstrumented="True"
  2. Include the namespace:

    CODE
    xmlns:appd="clr-namespace:AppDynamics.Agent.Forms;assembly=AppDynamics.Agent.Forms"

Example

Example of an xaml file with instrumented UI elements:

JSON
<ContentPage
xmlns:appd="clr-namespace:AppDynamics.Agent.Forms;assembly=AppDynamics.Agent.Forms" >
<StackLayout>
<Button
appd:UiInstrumentation.IsInstrumented="True"
Clicked="OnButtonClicked" />
<Entry
appd:UiInstrumentation.IsInstrumented="True" />
<ListView
appd:UiInstrumentation.IsInstrumented="True">
<ListView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Item l</x:String>
<x:String>Item 2</x:String>
</x:Array>
</ListView.ItemsSource>
</ListView>
</StackLayout>
</ContentPage>

You can also instrument properties from code behind (i.e. in the xaml.cs file):

CODE
using AppDynamics.Agent.Forms;
...
var button = new Button();
button.SetValue(UiInstrumentation.IsInstrumentedProperty, true);

The IsInstrumented property tracks the following events:

  1. Button - Button clicked
  2. ListView - Item selected
  3. Entry - Entry focused and entry unfocused