/// <summary> /// Populates the page with content passed during navigation. Any saved state is also /// provided when recreating a page from a prior session. /// </summary> /// <param name="navigationParameter">The parameter value passed to /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested. /// </param> /// <param name="pageState">A dictionary of state preserved by this page during an earlier /// session. This will be null the first time a page is visited.</param> protected override async void LoadState(Object navigationParameter, Dictionary<String, Object> pageState) { // Allow saved page state to override the initial item to display if (pageState != null && pageState.ContainsKey("SelectedItem")) { navigationParameter = pageState["SelectedItem"]; } String YWSID = "Bi9Fsbfon92vmD4DkkO4Fg"; String url; if (navigationParameter != null && navigationParameter != "") { model = (Model)navigationParameter; } if (model != null) { url = "http://api.yelp.com/business_review_search?term=food&location=" + model.Location + "&ywsid=" + YWSID; } else { Geolocator locator = new Geolocator(); Geoposition geoPos = await locator.GetGeopositionAsync(); Geocoordinate geoCoord = geoPos.Coordinate; url = "http://api.yelp.com/business_review_search?term=food&lat=" + geoCoord.Latitude + "&long=" + geoCoord.Longitude + "&ywsid=" + YWSID; } var httpClient = new HttpClient(); String content = await httpClient.GetStringAsync(url); response = JsonObject.Parse(content); if (response.GetNamedArray("businesses").Count == 0) { if (model != null) { model.error = true; GoBack(this, null); } else { this.Frame.Navigate(typeof(LocationEntryPage)); } } else { StopLoading(); PopulateNewRestaurant(); } }
private void Button_Click_1(object sender, RoutedEventArgs e) { model = new Model(); model.Location = Location.Text; this.Frame.Navigate(typeof(MainPage), model); }
public LocationEntryPage() { this.InitializeComponent(); this.NavigationCacheMode = NavigationCacheMode.Enabled; model = null; }
public MainPage() { this.InitializeComponent(); model = null; pageTitle.Text = "Restaurant near "; }