private async void CurrentOnGeofenceStateChanged(GeofenceMonitor sender, object args) { var reports = sender.ReadReports(); await CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.High, agileCallback : (async() => { foreach (GeofenceStateChangeReport report in reports) { switch (report.NewState) { case GeofenceState.Removed: break; case GeofenceState.Entered: Debug.WriteLine("entered"); foreach (MapElement mapElement in _map.MapElements) { if (mapElement is MapIcon) { MapIcon icon = (MapIcon)mapElement; if (icon.Title == report.Geofence.Id) { Sight s = mapElement.ReadData(); for (int i = CurrentRoute.Sights.IndexOf(s) + 1; i < CurrentRoute.Sights.Count; i++) { Sight sight = CurrentRoute.Sights[i]; if (sight.Name != "") { NextSight = sight; break; } } deleteRoutes(); redrawRoute(s.Position, NextSight.Position, true); ContentDialog1 dialog = new ContentDialog1(s); var result = await dialog.ShowAsync(); // primary button was clicked if (result == ContentDialogResult.Primary) { RedrawSight(icon); int geo = geofences.IndexOf(report.Geofence); geofences.RemoveAt(geo); page.Frame.Navigate(typeof(SightPage), s); break; } if (result == ContentDialogResult.None) { dialog.Hide(); } break; } } } break; case GeofenceState.Exited: Debug.WriteLine("kekekekekekekekekekkeke"); break; } } } )); }