I am programmatically adding graphics layers to a map and assigning maptips to these layers. I am running into a problem with binding, as the field values do not get displayed in the maptips. Thanks in advance for any insights.Alexprivate void DisplayLayerMaptips(FeatureSet featureSet, FeatureLayerConfig featureLayerConfig)
{
//Locate graphics layer by name
string maptipGraphicsLayerId = "Maptip_" + featureLayerConfig.Id.ToString();
GraphicsLayer graphicsLayerMaptip = (GraphicsLayer)MainMap.Layers[maptipGraphicsLayerId];
//If graphics layer is not present in the map, create it and assign maptip
if (graphicsLayerMaptip == null)
{
StackPanel maptipPanel = new StackPanel() { Orientation = Orientation.Vertical };
//Add field names and values (as bindings) to maptip
foreach (FieldConfig fieldConfig in featureLayerConfig.MaptipFields)
{
StackPanel fieldPanel = new StackPanel() { Orientation = Orientation.Horizontal };
TextBlock fieldNameText = new TextBlock() { Text = featureSet.FieldAliases[fieldConfig.Name]};
TextBlock fieldValueText = new TextBlock();
Binding binding = new Binding(fieldConfig.Name);
fieldValueText.SetBinding(TextBlock.TextProperty, binding);
fieldPanel.Children.Add(fieldNameText);
fieldPanel.Children.Add(fieldValueText);
maptipPanel.Children.Add(fieldPanel);
}
graphicsLayerMaptip = new GraphicsLayer() { ID = maptipGraphicsLayerId };
graphicsLayerMaptip.MapTip = maptipPanel;
MainMap.Layers.Add(graphicsLayerMaptip);
}
else
graphicsLayerMaptip.ClearGraphics();
//Add features to the graphics layer
foreach (Graphic feature in featureSet.Features)
{
feature.Symbol = CreateSymbolForMaptip(feature.Geometry);
graphicsLayerMaptip.Graphics.Add(feature);
}
}