protected override async void OnNavigatedTo()

in TrafficApp/MainPage.xaml.cs [134:151]


        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            if (e.NavigationMode == NavigationMode.New)
            {
                // Load location data from storage if it exists;
                // otherwise, load sample location data.
                var locations = await LocationDataStore.GetLocationDataAsync();
                if (locations.Count == 0) locations = await LocationDataStore.GetSampleLocationDataAsync();
                foreach (var location in locations) this.Locations.Add(location);

                // Start handling Geolocator and network status changes after loading the data 
                // so that the view doesn't get refreshed before there is something to show.
                LocationHelper.Geolocator.StatusChanged += Geolocator_StatusChanged;
                NetworkInformation.NetworkStatusChanged += NetworkInformation_NetworkStatusChanged;
            }
        }