2

我目前正在开发适用于 Windows Phone 的应用程序。它适用于 Bing 地图,并且我在地图上放置了多个具有不同存储属性的图钉。

我希望能够点击任何引脚,并打开一个显示引脚属性的新页面。

用户可以添加和删除引脚,因此它们的数量未知。那么,创建点击事件的最佳方式是什么?有没有办法动态创建 C# 代码?或者,我是否应该创建某种形式的“if”函数来检查每次点击屏幕时该位置是否有大头针?

4

1 回答 1

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));
}
于 2012-11-26T08:04:04.737 回答