Пример #1
0
        protected async override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            if (pageState != null)
            {
                if (pageState.ContainsKey("selectedArticleName") &&
                    pageState.ContainsKey("selectedArticleImage") &&
                    pageState.ContainsKey("selectedArticleObjectId"))
                {
                    var selectedArticleName     = pageState["selectedArticleName"].ToString();
                    var selectedGroupImage      = pageState["selectedArticleImage"].ToString();
                    var selectedArticleObjectId = pageState["selectedArticleObjectId"].ToString();

                    ArticlesInGroup article = new ArticlesInGroup();

                    article.Name     = selectedArticleName;
                    article.Image    = selectedGroupImage;
                    article.ObjectId = selectedArticleObjectId;


                    ((App)App.Current).SelectedArticle = new List <object>()
                    {
                        article
                    };
                    var context = this.DataContext as ArticleViewModel;
                    await context.GetArticle();
                }
            }

            DataTransferManager.GetForCurrentView().DataRequested += OnDataRequested;
        }
Пример #2
0
        public async Task GetArticle()
        {
            ArticlesInGroup article  = ((App)App.Current).SelectedArticle[0] as ArticlesInGroup;
            string          objectId = article.ObjectId;

            Article foundArticle = await this.dataService.GetArticleByObjectId(objectId);

            this.Article = foundArticle;
            this.RaisePropertyChanged("Article");
        }
Пример #3
0
        /// <summary>
        /// Preserves state associated with this page in case the application is suspended or the
        /// page is discarded from the navigation cache.  Values must conform to the serialization
        /// requirements of <see cref="SuspensionManager.SessionState"/>.
        /// </summary>
        /// <param name="pageState">An empty dictionary to be populated with serializable state.</param>
        protected override void SaveState(Dictionary <String, Object> pageState)
        {
            if (pageState != null)
            {
                if (((App)App.Current).SelectedArticle != null)
                {
                    ArticlesInGroup article = ((App)App.Current).SelectedArticle[0] as ArticlesInGroup;

                    pageState["selectedArticleName"]     = article.Name.ToString();
                    pageState["selectedArticleImage"]    = article.Image.ToString();
                    pageState["selectedArticleObjectId"] = article.ObjectId.ToString();
                }
            }

            DataTransferManager.GetForCurrentView().DataRequested -= OnDataRequested;
        }