/// <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="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            shopInfo = (GeneralInfo)e.NavigationParameter;
            if (shopInfo != null)
            {
                if (shopInfo.userFeedback == null)
                    feedbackCollection = new ObservableCollection<TransactionFeedback>();
                else
                    feedbackCollection = shopInfo.userFeedback;

                foreach(var feedback in feedbackCollection)
                {
                    if(feedback.Listing != null)
                    {
                        if(feedback.Listing.Images == null)
                            await feedback.Listing.getImages();
                        if (feedback.Listing.Images != null)
                            if (feedback.Listing.Images.Count > 0)
                                feedback.item_photo_url = feedback.Listing.Images[0].url_170x135;
                    }
                }

                ratingsListView.ItemsSource = feedbackCollection;
            }
        }
        /// <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="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            shopInfo = (GeneralInfo)e.NavigationParameter;
            if (shopInfo != null)
            {
                if (shopInfo.userFeedback == null)
                    feedbackCollection = new ObservableCollection<TransactionFeedback>();
                else
                    feedbackCollection = shopInfo.userFeedback;

                pRing.IsActive = true;                  // progress ring done manually this time
                pRing.Visibility = Visibility.Visible;

                foreach (var feedback in feedbackCollection)
                {
                    if (feedback.Listing != null)
                    {
                        if (feedback.Listing.Images == null)
                            await feedback.Listing.getImages();
                        if (feedback.Listing.Images != null)
                            if (feedback.Listing.Images.Count > 0)
                                feedback.item_photo_url = feedback.Listing.Images[0].url_170x135;
                    }
                }

                Loading.ControlProgressRing<TransactionFeedback>(shopInfo.userFeedback, pRing);     // progress ring
                ratingsListView.ItemsSource = feedbackCollection;
            }
        }
        /// <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="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            Window.Current.SizeChanged += Current_SizeChanged;
            parentSegment = (BrowseSegment)e.NavigationParameter;

            // null parameter error
            if (Loading.Null_Error<BrowseSegment>(parentSegment, loadErrorBlock))
            {
                LoadErrorPanel.Visibility = Visibility.Visible;     // Show the error
                errorVisibilityBlocker.Visibility = Visibility.Visible;
                return;
            }

            Loading.ControlProgressRing<BrowseSegment>(subSegments, pRing);     // progress ring

            // start loading the browse segments
            Task<ObservableCollection<BrowseSegment>> tbrowse = DataGET.findBrowseSegments(parentSegment.path);

            this.DefaultViewModel["title"] = parentSegment.name;

            // Finish loading
            subSegments = await tbrowse;
            //subSegments = parentSegment.sub_sections;
            this.DefaultViewModel["segments"] = subSegments;        // data binding
            
            Loading.ControlProgressRing<BrowseSegment>(subSegments, pRing);     // progress ring
        }
 /// <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="sender">
 /// The source of the event; typically <see cref="NavigationHelper"/>
 /// </param>
 /// <param name="e">Event data that provides both the navigation parameter passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
 /// a dictionary of state preserved by this page during an earlier
 /// session. The state will be null the first time a page is visited.</param>
 private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
 {
     // favorite listings
     FavoritesAccess.favoriteListings = new IncrementalSource<ListGetter, Listing>(1, -1, new List<Parameter>());
     productList.ItemsSource = FavoritesAccess.favoriteListings; // bind the listview to the remote collection so that the ItemInFavoritesList controls can access it
 
     // favorite users
     FavoritesAccess.favoriteUsers = new IncrementalSource<UserGetter, User>();
     shopList.ItemsSource = FavoritesAccess.favoriteUsers;
 }
        /// <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="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            user = App.user;
            if (user == null)
                return;

            this.DefaultViewModel["name"] = title.Text = user.Profile.first_name + " " + user.Profile.last_name; // set view model value and title text instantly, for user's real name
            this.DefaultViewModel["avatarSource"] = user.Profile.image_url_75x75;
            this.DefaultViewModel["username"] = user.Profile.login_name;

            this.DefaultViewModel["itemsBought"] = user.Profile.transaction_buy_count;

            this.DefaultViewModel["bio"] = user.Profile.bio;
        }
        /// <summary>
        /// Get temporary credentials and send the user to the web page for allowing the app access to their profile
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session. The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            string status = await App.getData.getTemporaryCredentials(true);                    // Get the oauth_token and oauth_token_secret
            
            if(status.Contains("ERROR:"))                                                       // Return if there's an error
            {
                NotifyUser(status);                                                             // Notify the User of an error before returning to previous page
            }
            else
            {
                // navigate to the log in URL, using the oauth_token and api_token (latter not really necessary)
                login_url = status + "?oauth_token=" + App.oauth_token + "&oauth_consumer_key=" + App.key;

                webView.Navigate(new Uri(login_url));                                           // Navigate to login URL ***************************************
            }      
        }
 /// <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="sender">
 /// The source of the event; typically <see cref="NavigationHelper"/>
 /// </param>
 /// <param name="e">Event data that provides both the navigation parameter passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
 /// a dictionary of state preserved by this page during an earlier
 /// session. The state will be null the first time a page is visited.</param>
 private void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
 {
     this.DefaultViewModel["AppVersion"] = Package.Current.Id.Version.Major.ToString() + "." + Package.Current.Id.Version.Minor.ToString();
 }
 /// <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="sender">
 /// The source of the event; typically <see cref="NavigationHelper"/>
 /// </param>
 /// <param name="e">Event data that provides both the navigation parameter passed to
 /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
 /// a dictionary of state preserved by this page during an earlier
 /// session.  The state will be null the first time a page is visited.</param>
 private async void NavigationHelper_LoadState(object sender, LoadStateEventArgs e)
 {
     App.user.cart = await CartAccess.getCarts();
     outerList.ItemsSource = App.user.cart.results;
 }
        /// <summary>
        /// Load the item info and set up the page sources according to the item
        /// </summary>
        /// <param name="sender">
        /// The source of the event; typically <see cref="NavigationHelper"/>
        /// </param>
        /// <param name="e">Event data that provides both the navigation parameter passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested and
        /// a dictionary of state preserved by this page during an earlier
        /// session.  The state will be null the first time a page is visited.</param>
        private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e)
        {
            initial_Orientation();
            Window.Current.SizeChanged += Current_SizeChanged;

            //this.DefaultViewModel["itemTitle"] = listing.title;   
            try
            {
                // assign the page listing to the one that was passed as an argument
                listing = (Listing)e.NavigationParameter;
            }
            catch
            {
            }

            // Set up variations ***************************************************
            // See var1Box and var2Box loaded events
            await setupVariations();

            // assign the page shop
            shop.general_info = listing.Shop;

            this.DefaultViewModel["listing"] = listing;
            this.DefaultViewModel["listingImages"] = listing.Images;            // Images  
            this.DefaultViewModel["shopInfo"] = shop.general_info;
            this.DefaultViewModel["shippingList"] = listing.shippingPractical;  //ShippingInfo;      // shipping


            // Select the first image to be displayed as the main image
            if (imgListView.Items.Count > 0)
                imgListView.SelectedIndex = 0;

            await loadUserFeedBack();                               // get user feedback
            this.DefaultViewModel["userReviews"] = user_reviews;        // user feedback


        }