Guest User

Untitled

a guest
Nov 18th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. private void ListBox_Places_SelectionChanged(object sender, SelectionChangedEventArgs e)
  2. {
  3. ListBox listbox = sender as ListBox;
  4. if(listbox.SelectedIndex < 0) return;
  5.  
  6. // ดึงค่า item ที่ถูกเลือก มาจาก listbox
  7. Place item = listbox.SelectedItem as Place;
  8.  
  9. // เลื่อน pivot ให้กลับไปยังหน้า map
  10. PivotRoot.SelectedIndex = 0;
  11. Image_Dest_Icon.Source = new BitmapImage(new Uri(item.image, UriKind.Relative));
  12. TextBlock_Dest_Name.Text = item.name;
  13. PushPin_Dest.Location = item.location;
  14.  
  15. ApplicationBarIconButton ApplicationBarButton_Direction = ApplicationBar.Buttons[0] as ApplicationBarIconButton;
  16.  
  17. // เลื่อน map ให้ครอบคลุมทั้งสองจุด
  18. if (PushPin_Me.Visibility == System.Windows.Visibility.Visible)
  19. {
  20. ApplicationBarButton_Direction.IsEnabled = true;
  21. Map_Main.ZoomLevel -= 0.5;
  22. Map_Main.SetView(LocationRect.CreateLocationRect(PushPin_Dest.Location, PushPin_Me.Location));
  23. }
  24. else
  25. {
  26. Map_Main.Center = PushPin_Dest.Location;
  27. Map_Main.ZoomLevel = 15;
  28. ApplicationBarButton_Direction.IsEnabled = false;
  29. }
  30.  
  31. // แสดง pushpin
  32. PushPin_Dest.Visibility = System.Windows.Visibility.Visible;
  33. listbox.SelectedIndex = -1;
  34. }
Add Comment
Please, Sign In to add comment