我目前正在开发适用于 Windows Phone 的应用程序。它适用于 Bing map ,我在 map 上放置了多个具有不同存储属性的图钉。
我希望能够点击任何引脚,然后打开一个显示引脚属性的新页面。
pin 可以由用户添加和删除,因此它们的数量未知。那么,创建点击事件的最佳方式是什么?有没有办法动态创建 C# 代码?或者,我是否应该创建某种形式的“if”函数来检查每次点击屏幕时该位置是否有图钉?
最佳答案
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));
}
关于c# - Bing map Windows Phone 上的图钉数量未知。我如何为他们每个人创建一个事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13380944/