2012-11-14 11 views
2

我目前正在爲Windows Phone開發一個應用程序。它適用於Bing地圖,並且我在地圖上放置了具有不同存儲屬性的多個引腳。Bing地圖Windows Phone上的圖釘數量未知。我如何爲他們每個人創建一個事件?

我希望能夠點擊任何引腳,並打開顯示引腳屬性的新頁面。

引腳可以由用戶添加和刪除,所以它們的數量是未知的。那麼,創建點擊事件的最佳方式是什麼?有沒有辦法動態創建C#代碼?或者,我是否應該創建某種形式的'if'函數來檢查每次屏幕是否在該位置有銷釘?

回答

0
I understand your problem. You want to click on pushpin and on that click event, you want to open a new page. Write the above code in PhoneApplicationPage_Loaded(). Here is the code.. 

private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e) 
{ 
map1.Center = new GeoCoordinate(21.7679, 78.8718); //coordinates for location of India 
map1.ZoomLevel = 5; 

Pushpin puspin1 = new Pushpin(); 
puspin1.Location = new GeoCoordinate(21.7679, 78.8718); 
puspin1.Background = new SolidColorBrush(Colors.Blue); 
puspin1.MouseLeftButtonUp += new MouseButtonEventHandler(puspin1_MouseLeftButtonUp); 
map1.Children.Add(puspin1); 

} 

void puspin1_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) 
{ 
    this.NavigationService.Navigate(new Uri("YourWindowName", UriKind.Relative)); 
} 
相關問題