2012-11-29 34 views
0

這是一個簡單的應用程序。它顯示基於數據綁定的動態多個圖釘。如何在Bing地圖,Windows Phone中切換顯示/隱藏圖釘信息框的狀態?

當用戶點擊圖釘時,信息框將如上圖所示顯示。

enter image description here

當用戶再次點擊圖釘。信息框將崩潰。

如果用戶點擊地圖中不是圖釘的任何區域。所有圖釘的信息框都會崩潰。

另一件事是;當信息框被點擊時,它將導航到該位置的詳細信息頁面。

這是我的資源部分。

<phone:PhoneApplicationPage.Resources> 
    <ControlTemplate x:Key="currentPushPin" TargetType="my:Pushpin"> 
     <Grid x:Name="ContentGrid" 
      Width="58" 
      Height="76" 
      Margin="0"> 
      <Image Source="images/currentPin.png" Stretch="Fill"/> 
     </Grid> 
    </ControlTemplate> 

    <ControlTemplate x:Key="normalPushPin" TargetType="my:Pushpin"> 
     <StackPanel> 
      <ContentPresenter x:Name="content" HorizontalAlignment="Center"/> 
      <Path Data="M0,0 L0,1 L1,0" 
         Fill="Black" Stretch="Fill" Margin="15,0" Height="12" 
           Width="18" Visibility="{Binding RelativeSource={RelativeSource TemplatedParent}, 
           Path=Content.Visibility, Mode=TwoWay}" HorizontalAlignment="Left" /> 
      <Image Source="images/Pin.png" Stretch="None" HorizontalAlignment="Left"/> 
     </StackPanel> 
    </ControlTemplate> 

    <DataTemplate x:Key="LogoTemplate"> 
     <my:Pushpin Background="#FFB6DE2E" Location="{Binding location}" Tap="Pushpin_Tap"> 
      <my:Pushpin.Content> 
       <Border Background="Black" Width="130" Visibility="Collapsed" x:Name="border" HorizontalAlignment="Center" > 
        <StackPanel> 
         <TextBlock TextAlignment="Center" Text="{Binding title}"/> 
        </StackPanel> 
       </Border> 
      </my:Pushpin.Content> 
     </my:Pushpin> 
    </DataTemplate> 
</phone:PhoneApplicationPage.Resources> 

這是我的Map和MapItemControl。

<my:Map ZoomLevel="10" Margin="0,-21,0,0" Name="myMap" CredentialsProvider="AsbJ8nhHrawCJNpgYLyPRSunojuLOKcZtMj_ZUEgEGW5dSsczqrQHDZwbi0i2bFY" Tap="map_Tap"> 
      <my:Pushpin Name="currentPin" Template="{StaticResource currentPushPin}" Margin="0,-22,0,0"> 
      </my:Pushpin> 
      <my:MapItemsControl ItemTemplate="{StaticResource LogoTemplate}" ItemsSource="{Binding PushpinCollection}" > 
      </my:MapItemsControl> 
     </my:Map> 

問題是我應該在這些事件處理程序中寫什麼代碼? 另一個問題是,如何讓信息框導航到其他頁面,如果它被輕敲。

//Event Handler for pushpins 
    private void Pushpin_Tap(object sender, System.Windows.Input.GestureEventArgs e) 
    { 
     //What I should write here? 
    } 


    private void map_Tap(object sender, System.Windows.Input.GestureEventArgs e) 
    { 
     //What I should write here? 
    } 

謝謝!

+0

我也對此感興趣。 –

回答

相關問題