Select to view content in your preferred language

Maptip help needed

769
3
03-16-2011 10:11 PM
IgressT
Emerging Contributor
Hi,
The problem I am having is extending MapTip control. I am trying to add extra stuff to the MapTip control such as showing images, weblinks, list boxes etc and the decision was not to change the map tip style but to download the source code for MapTip from codeplex and modify the code.

From the codeplex i have downloaded the source for the Map tip. It has two files MapTip.cs  and MapTip.Theme.xaml. I change the MapTip name to some name NewMapTip.

In my visual studio solution I added these two files and build the solution.
In the toolbox and under my solution controls I see a new control called NewMapTip.

I add the NewMapTip to my UI and set the required properties Graphics Layer, Title Memeber, Title.
However when I run the solution and hover over the graphics layer it doesnot show anything.

To verify if map tips show at all, I replace NewMapTip with MapTip from esri controls and bam the MapTip shows.

can anyone please tell me why my NewMapTip doesn't show up.
0 Kudos
3 Replies
DominiqueBroux
Esri Frequent Contributor
At first glance, I don't see why the control doesn't work after changing its name.
Check that you changed the name in xaml as well and that your NewMapTip.theme.xmal is included in the resources of the file 'Themes/generic.xaml'.

That being said, developping a new control is not the recommended approach. You could just change the template of the existing control (easy with the UI of Blend or with VS, you can copy the maptip style from MapTip.theme.xaml and modify it in your project.
0 Kudos
IgressT
Emerging Contributor
At first glance, I don't see why the control doesn't work after changing its name.
Check that you changed the name in xaml as well and that your NewMapTip.theme.xmal is included in the resources of the file 'Themes/generic.xaml'.

That being said, developping a new control is not the recommended approach. You could just change the template of the existing control (easy with the UI of Blend or with VS, you can copy the maptip style from MapTip.theme.xaml and modify it in your project.


Thanks!!!

Ok that didn't work. I included the name in the 'Themes/generic.xaml'.
However, as you suggested going by editing the style.

How to do it If i have to add these controls to the existing style

1. The map tip displays a title which you bind to a specific graphics attribute (using TitleMember). I want to use my own title in other words not use map tips title but I want to create a new label that displays the title of the map tip.
2. One more datagrid in addition to the grid that shows graphic attributes and how do i set the new data grids itemsource. I have a dependency property defined in my viewmodel that I want to bind to the new grid's itemsource.
3. A button and I have a class that implements ICommand. How do I attach the button click event trigger to my ICommand class.

<Style TargetType="local:MapTip">
  <Setter Property="HorizontalOffset" Value="20" />
  <Setter Property="VerticalOffset" Value="30" />
  <Setter Property="Background" Value="White" />
  <Setter Property="BorderThickness" Value="1" />
  <Setter Property="BorderBrush" Value="#FF666666" />
  <Setter Property="Template">
   <Setter.Value>
    <ControlTemplate TargetType="local:MapTip">
     <Grid x:Name="MapTip" MinWidth="50" >
      <VisualStateManager.VisualStateGroups>       
      </VisualStateManager.VisualStateGroups>

      <Grid.ColumnDefinitions>
       <ColumnDefinition Width="*" />
      </Grid.ColumnDefinitions>
      <Grid.RowDefinitions>
       <RowDefinition Height="20" />
       <RowDefinition Height="*" />
      </Grid.RowDefinitions>

      <Border CornerRadius="5" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Grid.RowSpan="2" />
      <Polyline Points="0,10 -10,-10 10,0" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding BorderThickness}" Fill="{TemplateBinding Background}" />

      <ContentPresenter Margin="5,5,5,0" Content="{TemplateBinding Title}" />
   
   <Stackpanel Orientation="Horizontal" Grid.Row="1">            
                        <data:DataGrid HeadersVisibility="None"
                                       ItemsSource="{TemplateBinding ItemsSource}"
                                       x:Name="MapTipData"
                                       Margin="5,5,5,5"
                                       AlternatingRowBackground="White"
                                       Height="0"
                                       Width="0"
                                       AutoGenerateColumns="True" />

                        <data:DataGrid x:Name="NewDataGrid" HeadersVisibility="None"                                       
                                       AutoGenerateColumns="True" />

   </Stackpanel>

   <Button x:name="btnGetImage"/>

                    </Grid>
    </ControlTemplate>
   </Setter.Value>
  </Setter>
 </Style>
0 Kudos
JenniferNery
Esri Regular Contributor
If you don't need to change the behavior of the MapTip and your only concern is to change its template, instead of extending Toolkit.MapTip, you can set GraphicsLayer.MapTip to your own user control. And your user control can include datagrid that binds to a different ItemsSource and button with Command that binds to your ICommand.
0 Kudos