<esri:SimpleMarkerSymbol x:Key="BlueMarkerSymbol" Color="Blue" Size="10" Style="Circle"> <esri:SimpleMarkerSymbol.ControlTemplate> <ControlTemplate> <Grid> <Ellipse Fill="{Binding Symbol.Color}" Width="{Binding Symbol.Size}" Height="{Binding Symbol.Size}" Stroke="Black" StrokeThickness="0.3" /> <StackPanel Margin="5"> <TextBlock Text="{Binding [MAINWORKCENTERDESCR]}" FontWeight="Bold" /> <StackPanel Orientation="Horizontal"> <TextBlock Text="Priority: " /> <TextBlock Text="{Binding [NOTIFICATIONPRIORITY]}" /> </StackPanel> </StackPanel> <Border BorderBrush="Black" BorderThickness="1" CornerRadius="2" /> </Grid> </ControlTemplate> </esri:SimpleMarkerSymbol.ControlTemplate> </esri:SimpleMarkerSymbol>
Solved! Go to Solution.
private FrameworkElement getMapTip(Graphic graphic) { Grid grid = new Grid(); grid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); grid.Margin = new Thickness(2); //create outer stack panel StackPanel outerStackPanel = new StackPanel(); outerStackPanel.Margin = new Thickness(5); //add border to grid Border border = new Border(); border.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0)); border.CornerRadius = new CornerRadius(2); border.Child = outerStackPanel; //put border around outer stack panel foreach (string attribute in _mapTipAttributes) { TextBlock txtBlock = new TextBlock(); txtBlock.Text = attribute + ": " + graphic.Attributes[attribute]; outerStackPanel.Children.Add(txtBlock); } grid.Children.Add(border); return grid; }
void queryTask_ExecuteCompleted(object sender, QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; if (featureSet == null || featureSet.Features.Count < 1) { MessageBox.Show("No features returned from query"); return; } GraphicsLayer graphicsLayer = _map.Layers["NotifLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); foreach (Graphic graphic in featureSet.Features) { graphic.Symbol = LayoutRoot.Resources["YellowMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphic.MapTip = getMapTip(graphic); graphicsLayer.Graphics.Add(graphic); } }
<esri:FeatureLayer.MapTip> <sdk:DataGrid ItemsSource="{Binding}" HeadersVisibility="None"/> </esri:FeatureLayer.MapTip>
<esri:FeatureLayer.MapTip> <sdk:DataGrid ItemsSource="{Binding Converter={StaticResource myDictionaryFilterConverter}}" HeadersVisibility="None"/> </esri:FeatureLayer.MapTip>
Likely there are lots of possibilities. One option is to first define your maptip as an ItemsControl allowing to display a list of attributes.
Something like this (for example with a datagrid):<esri:FeatureLayer.MapTip> <sdk:DataGrid ItemsSource="{Binding}" HeadersVisibility="None"/> </esri:FeatureLayer.MapTip>
Then you could develop a value converter taking an attributes dictionary as input and returning a dictionary with the attributes you want to display (how you filter the attributes is depending on your application).
Then you can use this converter in XAML:<esri:FeatureLayer.MapTip> <sdk:DataGrid ItemsSource="{Binding Converter={StaticResource myDictionaryFilterConverter}}" HeadersVisibility="None"/> </esri:FeatureLayer.MapTip>
Hope this helps.
private FrameworkElement getMapTip(Graphic graphic) { Grid grid = new Grid(); grid.Background = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); grid.Margin = new Thickness(2); //create outer stack panel StackPanel outerStackPanel = new StackPanel(); outerStackPanel.Margin = new Thickness(5); //add border to grid Border border = new Border(); border.BorderBrush = new SolidColorBrush(Color.FromArgb(255, 0, 255, 0)); border.CornerRadius = new CornerRadius(2); border.Child = outerStackPanel; //put border around outer stack panel foreach (string attribute in _mapTipAttributes) { TextBlock txtBlock = new TextBlock(); txtBlock.Text = attribute + ": " + graphic.Attributes[attribute]; outerStackPanel.Children.Add(txtBlock); } grid.Children.Add(border); return grid; }
void queryTask_ExecuteCompleted(object sender, QueryEventArgs args) { FeatureSet featureSet = args.FeatureSet; if (featureSet == null || featureSet.Features.Count < 1) { MessageBox.Show("No features returned from query"); return; } GraphicsLayer graphicsLayer = _map.Layers["NotifLayer"] as GraphicsLayer; graphicsLayer.ClearGraphics(); foreach (Graphic graphic in featureSet.Features) { graphic.Symbol = LayoutRoot.Resources["YellowMarkerSymbol"] as ESRI.ArcGIS.Client.Symbols.Symbol; graphic.MapTip = getMapTip(graphic); graphicsLayer.Graphics.Add(graphic); } }