Thank you for your reply Dominique,
The problem I'm having is due to TextBlocks being dynamically being generated with each one being assigned a different value by binding to the PropertyPath.
I cannot figure out how to test each textblock as it is created in order to set it's color based on the attribute value (i.e. if the value <= 50 the color = green else the color = red). I have written a ValueConverter that returns a brush based on the value passed into it. I just don't know how to get the value to pass into it.
Please see code below:
private PopupWindow CreateTipWindow(FeatureLayerInfo lyrInfo, List<string> outFields)
{
Dictionary<string, string> aliases = new Dictionary<string, string>();
foreach (Field f in lyrInfo.Fields) { if (f.Name != lyrInfo.DisplayField) aliases.Add(f.Name, f.Alias); }
PopupWindow tipWindow = new PopupWindow() { ShowArrow = false, ShowCloseButton = false, };
tipWindow.Content = CreateFeatureTipContent(outFields, aliases);
tipWindow.Background = this.myTaskbarWidget.Background;
Binding titleBinding = new Binding() { Path = new PropertyPath(string.Format("[{0}]", lyrInfo.DisplayField)) };
tipWindow.SetBinding(PopupWindow.TitleProperty, titleBinding);
if (lyrInfo.Name == "Building")
tipWindow.TitleFormat = "Installation ID" + ": {0}";
else
tipWindow.TitleFormat = lyrInfo.Name + ": {0}";
return tipWindow;
}
private FrameworkElement CreateFeatureTipContent(List<string> fields, Dictionary<string, string> aliases)
{
StackPanel stackBox = new StackPanel() { Margin = new Thickness(4, 1, 4, 1), Orientation = Orientation.Vertical };
foreach (string field in fields)
{
if (aliases.Keys.Contains(field))
{
TextBlock valueBlock = new TextBlock() { TextWrapping = TextWrapping.NoWrap };
Binding valueBinding = new Binding() { Path = new PropertyPath(string.Format("[{0}]", field)), StringFormat= aliases[field] + ": {0}" };
valueBlock.SetBinding(TextBlock.TextProperty, valueBinding);
stackBox.Children.Add(valueBlock);
}
}
return stackBox;
}
private void MapControl_MouseClick(object sender, Map.MouseEventArgs mouseEventArgs)
{