/// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// /// Page specific logic should be placed in event handlers for the /// <see cref="GridCS.Common.NavigationHelper.LoadState"/> /// and <see cref="GridCS.Common.NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. protected override void OnNavigatedTo(NavigationEventArgs e) { navigationHelper.OnNavigatedTo(e); if (e.NavigationMode == NavigationMode.New) { Logger.LogAgent.GetInstance().WriteLog(this.GetType().ToString()); } this.blogger = e.Parameter as Blogger; // for listview binding this.Author = new Author() { Avatar = this.blogger.Avatar, Name = this.blogger.Name, Uri = "http://www.cnblogs.com/" + this.blogger.BlogApp + "/" }; AuthorAvatar.DataContext = this.Author; TitleControl.Text = this.Author.Name; this.authorDS = new AuthorPostsDS(this.blogger.BlogApp); this.authorDS.OnLoadMoreStarted += TitleControl.DS_OnLoadMoreStarted; this.authorDS.OnLoadMoreCompleted += TitleControl.DS_OnLoadMoreCompleted; this.gv_AuthorPosts.ItemsSource = this.authorDS; this.gv_SimplePosts.ItemsSource = this.authorDS; this.DataContext = this.authorDS; UpdateUI(); }
/// <summary> /// The methods provided in this section are simply used to allow /// NavigationHelper to respond to the page's navigation methods. /// <para> /// Page specific logic should be placed in event handlers for the /// <see cref="NavigationHelper.LoadState"/> /// and <see cref="NavigationHelper.SaveState"/>. /// The navigation parameter is available in the LoadState method /// in addition to page state preserved during an earlier session. /// </para> /// </summary> /// <param name="e">Provides data for navigation methods and event /// handlers that cannot cancel the navigation request.</param> protected override async void OnNavigatedTo(NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.New) { Logger.LogAgent.GetInstance().WriteLog(this.GetType().ToString()); } this.btn_NightMode.DataContext = CNBlogs.DataHelper.DataModel.CNBlogSettings.Instance; FunctionHelper.Functions.SetTheme(this); this.navigationHelper.OnNavigatedTo(e); if (e.NavigationMode == NavigationMode.New) { this.authorDS = null; this.DataContext = null; if (e.Parameter is Blogger) { this.blogger = e.Parameter as Blogger; this.Author = new Author() { Avatar = this.blogger.Avatar, Name = this.blogger.Name, BlogApp = this.blogger.BlogApp, Uri = this.blogger.Link == null ? string.Empty : this.blogger.Link.Href }; var detailedBlogger = await APIWrapper.Instance.GetBloggerByAuthorAsync(this.Author); if (detailedBlogger != null) { this.blogger = detailedBlogger; this.Author.Avatar = detailedBlogger.Avatar; this.Author.Uri = detailedBlogger.Link == null ? string.Empty : detailedBlogger.Link.Href; } this.DataContext = this; // for listview binding this.authorDS = new AuthorPostsDS(this.blogger.BlogApp); } else if (e.Parameter is string) { string blogapp = (string)e.Parameter; this.authorDS = new AuthorPostsDS(blogapp); } this.authorDS.OnLoadMoreStarted += authorDS_OnLoadMoreStarted; this.authorDS.OnLoadMoreCompleted += authorDS_OnLoadMoreCompleted; this.lv_AuthorPosts.ItemsSource = this.authorDS; } }