2011-03-21 62 views
2

Howdy, 我想在地圖上的單獨圖層上生成多個圖釘位置。這些圖釘應代表這個座標的位置。因此,他們應該顯示一些額外的信息,一旦用戶點擊/觸摸圖釘,應該可見。PushPin中的自定義模板

整個解決方案完全基於代碼(添加了圖釘)。

我已經在這裏上具有sa,我應該把一個看不見的按鈕圖釘背後 - 但我不能肯定我應該怎麼做。

如果有人有提示,這將是偉大的,會帶我前進!

由於

<DataTemplate x:Key="PushpinControlTemplate2"> 
    <Grid x:Name="ContentGrid"> 
     <StackPanel Orientation="Vertical"> 

      <Grid Background="{TemplateBinding Background}" 
             HorizontalAlignment="Left" 
             MinHeight="10" 
             MinWidth="29"> 
       <Hyperlinkbutton HorizontalAlignment="Center" Content="{binding}" Click="clicker" Margin="0"/> 
      </Grid> 

      <Polygon Fill="{TemplateBinding Background}" 
           Points="0,0 29,0 0,29" 
           Width="29"        
           Height="29" 
           HorizontalAlignment="Left"/> 
     </StackPanel> 
    </Grid> 
</DataTemplate> 

這是我的代碼,我使用至今,函數答題被定義,但是我總是錯誤 'AG_E_PARSER_BAD_PROPERTY_VALUE [行:5位置:98]'

回答

6

Pushpin-Styles in Bing Maps for the Windows Phone帖子應該告訴你一切你需要知道的樣式圖釘。

+0

剩下的問題是我如何能在C#代碼「的ContentTemplate」屬性設置爲相應的DataTemplate – theXs 2011-03-21 16:13:58

+2

將它設置爲資源,然後從那裏加載,例如'myPushPin.ContentTemplate =(ContentTemplate)Application.Current.Resources [「TemplateKey」];或從XAML反序列化它,例如'myPushPin.ContentTemplate =(ContentTemplate)XamlLoader.Load(templateString);' – 2011-03-21 17:15:46

+0

我用更多的牛肉更新了我的第一篇文章。 – theXs 2011-03-23 16:22:57