Sorry for the delay.. this is how i did it C# code
I have a method which executes a GP task that returns a graphics layer
I iterate each graphic, create an observable collection and bind the observable collection to the data grid.
there are other ways to bind but this worked for me when used with the chart
Hope this helps
// GP task that returns graphics
public void Execute(object parameter)
{
Geoprocessor getData = new Geoprocessor();
getData.Url = "GP task URL...";
getData.Failed += this.GP_Failed;
getData.GetResultDataCompleted += this.GP_GetResultDataCompleted;
getData.GetResultDataAsync(this.jobId, "parameter");
}
// The event raised when GP task successful
void GP_GetResultDataCompleted(object sender, GPParameterEventArgs e)
{
object attributeValue = null;
// Internal class object
CategoryAttributes categoryAttributes = new CategoryAttributes();
if (e.Parameter is GPFeatureRecordSetLayer)
{
GPFeatureRecordSetLayer gpLayer = e.Parameter as GPFeatureRecordSetLayer;
// Create a new graphics layer
GraphicsLayer graphicsLayer = new GraphicsLayer();
graphicsLayer.ID = "GraphicsLayer";
// Add the graphics to the graphics layer and an observable collection that is binded to a data grid
foreach (Graphic graphic in gpLayer.FeatureSet.Features)
{
CategoryAttribute categoryAttribute = new CategoryAttribute();
attributeValue = g.Attributes.Where(x => x.Key.Contains("CategoryCount")).SingleOrDefault().Value;
if (attributeValue != null)
{
categoryAttribute.Count = attributeValue.ToString();
}
attributeValue = g.Attributes.Where(x => x.Key.Contains("CategoryValue")).SingleOrDefault().Value;
if (attributeValue != null)
{
categoryAttribute.Value = attributeValue.ToString();
}
attributeValue = g.Attributes.Where(x => x.Key.Contains("CategoryAmount")).SingleOrDefault().Value;
if (attributeValue != null)
{
categoryAttribute.Amount = attributeValue.ToString();
}
categoryAttributes.Add(categoryAttribute);
graphicsLayer.Graphics.Add(graphic);
}
// Add to map
this.myMap.Layers.Add(graphicsLayer);
// Bind data to data grid
this.MyDataGrid.ItemsSource = categoryAttributes;
}
}
// Internal classes for creating the observable collection
internal class CategoryAttributes : ObservableCollection<CategoryAttribute>
{
}
internal class CategoryAttribute
{
public double CategoryCount { get; set; }
public double CategoryValue { get; set; }
public double CategoryAmount { get; set; }
}