in TrafficApp/MainPage.xaml.cs [438:452]
private LocationData GetLocation(FrameworkElement element) =>
(element.FindName("Presenter") as FrameworkElement).DataContext as LocationData;
/// <summary>
/// Registers or unregisters the traffic monitoring background task depending
/// on whether the number of tracked locations changes from 1 to 0 or from 0 to 1.
/// </summary>
/// <param name="isIncrement">true if a location was just flagged;
/// false if a location was just unflagged.</param>
private void UpdateTrafficMonitor(bool isIncrement)
{
var monitoredLocationCount = this.Locations.Count(location => location.IsMonitored);
if (isIncrement && monitoredLocationCount == 1) LocationHelper.RegisterTrafficMonitor();
else if (monitoredLocationCount == 0) LocationHelper.UnregisterTrafficMonitor();
}