/// <summary>
        /// Queries related records for specified feature ID.
        /// </summary>
        private async Task QueryRelatedRecordsAsync()
        {
            var featureID = (Int64)AddButton.Tag;
            var layer     = MyMapView.Map.Layers["ServiceRequests"] as ArcGISDynamicMapServiceLayer;
            var id        = layer.VisibleLayers.FirstOrDefault();
            var task      = new QueryTask(new Uri(string.Format("{0}/{1}", layer.ServiceUri, id)));

            if (relationship == null)
            {
                relationship = await GetRelationshipAsync();
            }
            var parameters = new RelationshipParameters(new List <long>(new long[] { featureID }), relationship.ID);

            parameters.OutFields = new OutFields(new string[] { "objectid" });
            var result = await task.ExecuteRelationshipQueryAsync(parameters);

            if (result != null && result.RelatedRecordGroups != null && result.RelatedRecordGroups.ContainsKey(featureID))
            {
                RelatedRecords.ItemsSource = result.RelatedRecordGroups[featureID];
                Records.IsEnabled          = true;
            }
        }
 /// <summary>
 /// Queries related records for specified feature ID.
 /// </summary>
 private async Task QueryRelatedRecordsAsync()
 {
     var featureID = (Int64)AddButton.Tag;
     var layer = MyMapView.Map.Layers["ServiceRequests"] as ArcGISDynamicMapServiceLayer;
     var id = layer.VisibleLayers.FirstOrDefault();
     var task = new QueryTask(new Uri(string.Format("{0}/{1}", layer.ServiceUri, id)));
     if (relationship == null)
         relationship = await GetRelationshipAsync();
     var parameters = new RelationshipParameters(new List<long>(new long[] { featureID }), relationship.ID);
     parameters.OutFields = new OutFields(new string[] { "objectid" });
     var result = await task.ExecuteRelationshipQueryAsync(parameters);
     if (result != null && result.RelatedRecordGroups != null && result.RelatedRecordGroups.ContainsKey(featureID))
     {
         RelatedRecords.ItemsSource = result.RelatedRecordGroups[featureID];
         Records.IsEnabled = true;
     }
 }