protected override void OnNavigatedTo(NavigationEventArgs e) { if (DataContext != null) return; var selectedIndex = ""; if (!NavigationContext.QueryString.TryGetValue("selectedPlace", out selectedIndex)) return; int i = Convert.ToInt32(selectedIndex); p = (from pl in App.ViewModel.Items where pl.ID == i select pl).FirstOrDefault(); PopulateMap(p); }
private BitmapImage GetSource(ItemViewModel p) { switch (p.IncidentTypeID) { case 1: return new BitmapImage(new Uri("/Assets/mapControlIconWarn.png", UriKind.Relative)); case 2: return new BitmapImage(new Uri("/Assets/mapControlIconCar.png", UriKind.Relative)); case 3: return new BitmapImage(new Uri("/Assets/mapControlIconWork.png", UriKind.Relative)); case 4: return new BitmapImage(new Uri("/Assets/mapControlIconFlood.png", UriKind.Relative)); } return null; }
private void PopulateMap(ItemViewModel pl) { pl.LastUpdate = "Updated: " + pl.UpdatedAt.ToString("f"); pl.Icon = GetSource(pl); pl.Coordinate = new GeoCoordinate(pl.Latitude, pl.Longitude); List<ItemViewModel> places = new List<ItemViewModel>(); places.Add(pl); ObservableCollection<DependencyObject> children = MapExtensions.GetChildren(myMap); MapItemsControl obj = new MapItemsControl(); obj.Items.Clear(); obj.ItemsSource = null; obj = children.FirstOrDefault(x => x is MapItemsControl) as MapItemsControl; if (obj != null && obj.Items.Count == 0) { obj.ItemsSource = places; TbkTitle.Text = pl.Title; TbkReport.Text = pl.Report; TbkUpdated.Text = "Updated: " + pl.UpdatedAt.ToString("f"); } }