/// <summary> /// Called when the user selects a new stop. /// </summary> public void SelectNewStop(TripStop stop) { // This stop is already selected: if (this.selectedStop != null && string.Equals(this.selectedStop.StopId, stop.StopId, StringComparison.OrdinalIgnoreCase)) { return; } this.SelectStop(stop.StopId); var stopSelected = this.StopSelected; if (stopSelected != null) { stopSelected(this, new StopSelectedEventArgs(stop.Name, stop.StopId, stop.Direction, stop.Latitude, stop.Longitude)); } }
/// <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); } } } }
/// <summary> /// Selects a stop. /// </summary> public void SelectStop(string stopId) { if (selectedStop != null) { selectedStop.IsSelectedStop = false; } this.selectedStop = (from tripStop in this.tripDetails.TripStops where string.Equals(stopId, tripStop.StopId, StringComparison.OrdinalIgnoreCase) select tripStop).FirstOrDefault(); this.SelectedStopId = stopId; if (this.selectedStop != null) { this.selectedStop.IsSelectedStop = true; } }