As Thang mentionned, the closest sample of what you have to do is this one : http://help.arcgis.com/en/webapi/silverlight/samples/start.htm#ToolkitFeatureDataForm
It could be a good idea to make first working this sample in your context and then try to adapt it to your exact need.
I also have the same problem, and did as Thang said: to set the FeatureDataForm.GraphicSource to the graphic that came back from the query. That did not work.But using the graphic from the MouseLeftButtonUp event does work.This example works:
private void MyFeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs args)
{
FeatureLayer featureLayer = sender as FeatureLayer; //references MyFeatureLayer defined in Map Layers in xaml
featureDataForm.FeatureLayer = featureLayer;
featureDataForm.GraphicSource = args.Graphic;
}
But this example does not:
private void MyFeatureLayer_MouseLeftButtonUp(object sender, GraphicMouseButtonEventArgs args)
{
FeatureLayer featureLayer = sender as FeatureLayer;
//perform query instead on the objectid, to demonstrate query
int objectId = (int) args.Graphic.Attributes["OBJECTID"];
QueryTask queryTask = new QueryTask(featureLayer.Url);
queryTask.ExecuteCompleted += MS4QueryTask_ExecuteCompleted;
queryTask.Failed += MS4QueryTask_Failed;
Query query = new ESRI.ArcGIS.Client.Tasks.Query();
query.ObjectIDs = new int[1] { objectId };
query.OutFields.Add("*");
query.ReturnGeometry = true;
//If query is sucessful fire off AQueryTask_ExecuteCompleted
queryTask.ExecuteAsync(query);
}
private void MS4QueryTask_ExecuteCompleted(object sender, ESRI.ArcGIS.Client.Tasks.QueryEventArgs args)
{
FeatureSet featureSet = args.FeatureSet;
if (featureSet != null && featureSet.Features.Count > 0)
{
foreach (Graphic feature in featureSet.Features)
{ //should only be 1 since we searched on objectid
featureDataForm.FeatureLayer = MyFeatureLayer;
featureDataForm.GraphicSource = args.Graphic;
}
}
}
Maybe I overlooked something obvious, but it seems that the Graphic coming back from the query is substantially different from the graphic coming from the GraphicMouseButtonEventArgs. maybe the graphic coming back from the query doesnt have the required association to the feature layer. Since everything else to do with the featureDataForm is essentially the same.