public void Attach( DependencyObject associatedObject ) { if ( DesignMode.DesignModeEnabled ) { return; } AssociatedObject = associatedObject; _map = (MapControl) associatedObject; _labelsOverlay = new Image(); _labelsOverlay.ImageOpened += ( _, __ ) => { Geopoint topLeft; _map.GetLocationFromOffset( new Point( 0, 0 ), out topLeft ); MapControl.SetLocation( _labelsOverlay, topLeft ); _labelsOverlay.Visibility = Visibility.Visible; }; _map.Children.Add( _labelsOverlay ); _map.Loaded += ( _, __ ) => { _vm = (MainViewModel) _map.DataContext; OnFloorChanged( _vm.Properties.Floor ); OnItemsChanged( _vm.SearchResults ); _properties = _vm.Properties; _vm.Properties.ListenToProperty( x => x.Center, UpdateLabelsOverlay ); _vm.Properties.ListenToProperty( x => x.Floor, UpdateLabelsOverlay ); _vm.Properties.ListenToProperty( x => x.ZoomLevel, UpdateLabelsOverlay ); UpdateLabelsOverlay(); _vm.Properties.ListenToProperty( x => x.Floor, () => OnFloorChanged( _vm.Properties.Floor ) ); _vm.ListenToProperty( x => x.SearchResults, () => OnItemsChanged( _vm.SearchResults ) ); var buildingsDataSource = EpflTileSources.GetForBuildings( _vm.Properties ); _map.TileSources.Add( new MapTileSource( buildingsDataSource ) ); }; // HACK: Force the map to always face North, so that buildings labels are shown properly. _map.HeadingChanged += ( _, __ ) => _map.Heading = 0; }