private void OnViewModelMapViewRequested(object sender, GameMapViewModel.MapViewRequestedEventArgs e)
 {
     if (_isMapReady)
     {
         SetMapView(e);
     }
     else
     {
         // Delays this request for after the map is ready.
         _delayedMapViewRequest = e;
     }
 }
 private void SetMapView(GameMapViewModel.MapViewRequestedEventArgs e)
 {
     // Updates the view according to the event.
     if (e.TargetBounds != null)
     {
         // Sets the map to show the target bounds.
         MapControl.SetView(e.TargetBounds, e.Animation);
     }
     else
     {
         // Sets the view using the target center and zoom level.
         MapControl.SetView(e.TargetCenter, e.TargetZoomLevel, e.Animation);
     }
 }
        private void OnMapReady()
        {
            // Waits a bit for the map to be ready.
            System.Threading.Tasks.Task.Delay(250).Wait();

            // The map is now ready.
            _isMapReady = true;

            // Initializes the map item controls.
            BindMapItemsControlItemsSource("ThingsPushpins", ViewModel.ThingGroups);
            BindMapItemsControlItemsSource("ZoneLabelsPushpins", ViewModel.Zones);

            // Applies a map view request that was issued before the map was ready.
            if (_delayedMapViewRequest != null)
            {
                SetMapView(_delayedMapViewRequest);

                _delayedMapViewRequest = null;
            }
        }