Inheritance: INotifyPropertyChanged
 public StationStatusUserControl(Station station)
 {
     InitializeComponent();
       _station = station;
       this.DataContext = _station;
 }
Ejemplo n.º 2
0
        void SelectStationOnMap(Station selectedStation)
        {
            App.ViewModel.MapCenter = selectedStation.Coordinate;
              this.map.Center = selectedStation.Coordinate;

              // Show a background behind the selected station
              selectedStationLayer.Children.Clear();
              Image selectedStationBackgroundImage = new Image();
              selectedStationBackgroundImage.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("Images/[email protected]", UriKind.Relative));
              selectedStationBackgroundImage.Opacity = 0.8;
              selectedStationBackgroundImage.Stretch = System.Windows.Media.Stretch.None;
              PositionOrigin position = PositionOrigin.Center;
              selectedStationLayer.AddChild(selectedStationBackgroundImage, selectedStation.Coordinate, position);

              GeneralTransform gt = this.TransformToVisual(this.map as UIElement);
              Point offset = gt.Transform(new Point(0, 0));
              double controlTop = offset.Y;
              double controlLeft = offset.X;

              // Show Popup
              if (stationStatus == null)
              {
            stationStatus = new StationStatusUserControl(selectedStation);
            buyNowScreen = new Popup();
            buyNowScreen.Child = stationStatus;
            buyNowScreen.IsOpen = true;
            buyNowScreen.VerticalOffset = controlTop * (-1) + 30;
            buyNowScreen.HorizontalOffset = (this.LayoutRoot.ActualWidth + controlLeft - stationStatus.Width) / 2;
            buyNowScreen.Closed += (s1, e1) =>
            {
              // Add you code here to do something
              // when the Popup is closed
            };
              }
              else
              {
            stationStatus.DataContext = selectedStation;
            buyNowScreen.IsOpen = true;
              }
        }