/// <summary>
 /// Fire the view models' event.
 /// </summary>
 private void OnPointerPressed(object sender, PointerRoutedEventArgs e)
 {
     if (this.viewModel != null)
     {
         // Find the Map control that we're parented to:
         MapControl mapControl = ControlUtilities.GetParent <MapControl>(this.Parent);
         if (mapControl != null)
         {
             MapControlViewModel mapControlViewModel = mapControl.DataContext as MapControlViewModel;
             if (mapControlViewModel != null)
             {
                 mapControlViewModel.SelectStop(this.viewModel);
             }
         }
     }
 }
        /// <summary>
        /// Fire the view models' event.
        /// </summary>
        private void OnTap(object sender, GestureEventArgs e)
        {
            FrameworkElement element = sender as FrameworkElement;

            if (this.viewModel != null && element != null)
            {
                // Find the Map control that we're parented to:
                MapControl mapControl = ControlUtilities.GetParent <MapControl>(element.Parent);
                if (mapControl != null)
                {
                    MapControlViewModel mapControlViewModel = mapControl.DataContext as MapControlViewModel;
                    if (mapControlViewModel != null)
                    {
                        mapControlViewModel.SelectStop(this.viewModel);
                    }
                }
            }
        }
        /// <summary>
        /// Scrolls to a specific trip stop.
        /// </summary>
        private void ScrollToTripStop(TripStop tripStop)
        {
            if (tripStop != null)
            {
                var contentPresenter = this.itemsControl.ContainerFromItem(tripStop) as ContentPresenter;
                if (contentPresenter != null)
                {
                    ScrollViewer scrollViewer = ControlUtilities.GetParent <ScrollViewer>(this.Parent);
                    if (scrollViewer != null)
                    {
                        // So now we need to find where this stop is in the control:
                        var transform = contentPresenter.TransformToVisual(scrollViewer);
                        var point     = transform.TransformPoint(new Windows.Foundation.Point(0, 0));

                        double newVerticalOffset = point.Y + scrollViewer.VerticalOffset;
                        scrollViewer.ChangeView(null, newVerticalOffset, null);
                    }
                }
            }
        }