0
votes

I have several pushpins on the map. When i hover with my mouse over the pushpins i get a dialogbox with some information in it. Now i also want some additional information when i click on the same pushpin. But i can't really figure out how to do this. I tried some things but it didn't work...

This is my code:

 <bing:MapItemsControl ItemsSource="{Binding Items}">
    <bing:MapItemsControl.ItemTemplate>
      <DataTemplate>
        <bing:Pushpin  bing:MapLayer.Position="{Binding Location}" Background="{Binding Color, Converter={StaticResource brushConverter}}">

            <ToolTipService.ToolTip>
              <StackPanel>
                <TextBlock Text="{Binding Address}" />
                <TextBlock Text="{Binding Description}" />
              </StackPanel>
            </ToolTipService.ToolTip>

        </bing:Pushpin>
      </DataTemplate>
    </bing:MapItemsControl.ItemTemplate>
  </bing:MapItemsControl>
</bing:Map>

Has somebody tried to do this or know how to do this, by far thanks!

1
You should just be able to use Template Binding to override the defaults. Inside that stack panel add whatever extras you're wanting.jstell

1 Answers

0
votes

I know this is an old question, but maybe it will shine a little light on the right solution, and help someone else, if not you.

As I understand, the Tooltip stuff is already working, you just want to handle the clicks.

So here are some suggestions:

1 - The novice solution: You can handle the event from the code behind. Since only Buttons have the Click event, you can't use that, but I think MouseLeftButtonDown, or even better MouseLeftButtonUp are equally good for this. Of course, if you have different maps on different controls, you will have to repeat this code on every one of them.

2 - The advanced solution: Use Behaviors! They are like tiny extensions that can cling on to controls and extend their functionality. In your place, I would put a Behavior on the Pushpins, that would open a panel to display the info you want. You can read more about this topic under the link above!