/// <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) { if (e.PageState != null && e.PageState.ContainsKey("CurrentSite")) { var result = await StringIOExtensions.ReadFromFile("data.txt"); var json = await JsonConvert.DeserializeObjectAsync<ObservableCollection<SiteModel>>(result); if (json != null) { ServiceManager.Sites = json; } var ds = this.DataContext as PageViewModel; if (ds != null) { await ds.LoadData(e.PageState["CurrentSite"].ToString(), null); if (e.PageState.ContainsKey("SelectedIndex")) { ds.CurrentSite.SelectedIndex = e.PageState["SelectedIndex"].ToInt(); PnlPivot_OnLoaded(null,null); } } e.PageState["CurrentSite"] = null; e.PageState["SelectedIndex"] = null; } else { var ds = DataContext as PageViewModel; if (ds != null) { await ds.LoadData(e.NavigationParameter.ToString(), null); } } }
/// <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> private async void navigationHelper_LoadState(object sender, LoadStateEventArgs e) { var ds = this.DataContext as SearchResultViewModel; if (ds != null) { ds.QueryText = e.NavigationParameter as String; await ds.LoadData(); } }
/// <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) { if (e.PageState != null && e.PageState.ContainsKey("SelectedItem")) { var result = await StringIOExtensions.ReadFromFile("data.txt"); var json = await JsonConvert.DeserializeObjectAsync<ObservableCollection<SiteModel>>(result); if (json != null) { ServiceManager.Sites = json; } var ds = this.DataContext as ItemViewModel; if (ds != null) { var itemId = e.PageState["SelectedItem"].ToString(); ds.CurrentPage = await ServiceManager.GetPageAsync(itemId); ds.SelectedItem = await ServiceManager.GetItemAsync(itemId); } e.PageState["SelectedItem"] = null; } else { var itemId = e.NavigationParameter.ToString(); PageModel selectedPage = await ServiceManager.GetPageAsync(itemId); if (selectedPage != null) { var ds = DataContext as ItemViewModel; if (ds != null) { ds.CurrentPage = selectedPage; ds.SelectedItem = selectedPage.Items.FirstOrDefault(x => x.Id.Equals(itemId)); } } } }
/// <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) { var ds = DataContext as MainViewModel; if (ds != null) { await ds.LoadData(null); } }