private void GPTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e) { GraphicsLayer graphicslayer = new GraphicsLayer(); graphicslayer.ID = "xxx"; // Adding features to graphics layer // Rendering graphicslayer.Renderer = cbr; // Refresh graphics layer graphicslayer.Refresh(); this.Map.Layers.Add(graphicslayer); MapTip mp = new MapTip(); mp.GraphicsLayer = graphicslayer; mp.TitleMember = "grid_code"; mp.Title = "Pollution Levels"; mp.Visibility = Visibility.Visible; }
private void GPTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e) { var graphicslayer = new GraphicsLayer() { ID = "xxx", Renderer = cbr, MapTip = new ContentControl() { ContentTemplate = (DataTemplate)Resources["gpTaskMapTipTemplate"] } }; graphicslayer.MapTip.SetBinding(ContentControl.ContentProperty, new System.Windows.Data.Binding()); Map.Layers.Add(graphicslayer); }then on your usercontrol XAML page:
<UserControl.Resources> <DataTemplate x:Key="gpTaskMapTipTemplate"> <Border Background="White"> <StackPanel> <TextBlock Text="{Binding [grid_code]}" Foreground="White" /> </StackPanel> </Border> </DataTemplate> </UserControl.Resources>If you would rather use the ESRI.ArcGIS.Client.Toolkit.MapTip control, you have to declare it separately and add it to your usercontrol's visual tree, whether through XAML or code.
It looks like you're confusing the two different MapTip classes. The ESRI.ArcGIS.Client.MapTip class would probably work better for what you're trying to do:private void GPTask_ExecuteCompleted(object sender, GPExecuteCompleteEventArgs e) { var graphicslayer = new GraphicsLayer() { ID = "xxx", Renderer = cbr, MapTip = new ContentControl() { ContentTemplate = (DataTemplate)Resources["gpTaskMapTipTemplate"] } }; graphicslayer.MapTip.SetBinding(ContentControl.ContentProperty, new System.Windows.Data.Binding()); Map.Layers.Add(graphicslayer); }then on your usercontrol XAML page:<UserControl.Resources> <DataTemplate x:Key="gpTaskMapTipTemplate"> <Border Background="White"> <StackPanel> <TextBlock Text="{Binding [grid_code]}" Foreground="White" /> </StackPanel> </Border> </DataTemplate> </UserControl.Resources>If you would rather use the ESRI.ArcGIS.Client.Toolkit.MapTip control, you have to declare it separately and add it to your usercontrol's visual tree, whether through XAML or code.
So apparently the attribute "grid_code" in your service is of type ObservableCollection. Try replacing the textbox in the maptip with a DataGrid and bind the ItemsSource to [grid_code].
Ignore my last post. You're seeing the default template, which means Silverlight can't locate your datatemplate. The only way my code would work is if you're creating the maptip within the usercontrol codebehind. Anywhere else and you will need to add the datatemplate XAML to the application resources, either in App.xaml or one of the merged dictionaries.
<UserControl.Resources> <DataTemplate x:Key="myLabel" > <Border Background="Beige" > <StackPanel> <TextBlock Text="{Binding [NAME]}" FontSize="8" Foreground="White" /> </StackPanel> </Border> </DataTemplate> </UserControl.Resources>
Could you please suggest where exactly to insert the following code?