/// <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)
        {
            bool failed = false;

            try
            {
                await Helper.ShowSystemTrayAsync(Colors.CornflowerBlue, Colors.White, text : "loading...");

                var bookkey = (string)e.NavigationParameter;

                //Key=nce&bookKey=xingainian1
                var bookInfo = await GetBookDataSource.GetBookAsync(key : "nce", bookKey : bookkey);

                this.DefaultViewModel["Book"] = bookInfo;

                //key=nce&bookKey=xingainian1
                var bookUnitList = await GetBookUnitListDataSource.GetBookUnitListAsync(key : "nce", bookKey : bookkey);

                this.DefaultViewModel["BookUnitList"] = bookUnitList;
            }
            catch (Exception)
            {
                failed = true;
            }
            await Helper.HideSystemTrayAsync(originbackgroundColor, originforegroundColor, originopacity);

            if (failed)
            {
                MessageDialog md2 = new MessageDialog(Constants.WININET_E_NAME_NOT_RESOLVED, Constants.NETWORK_CONNECTION);
                await md2.ShowAsync();
            }
        }
Example #2
0
        /// <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)
        {
            bool failed = false;

            try
            {
                await Helper.ShowSystemTrayAsync(Colors.CornflowerBlue, Colors.White, text : "loading...");

                // TODO: Create an appropriate data model for your problem domain to replace the sample data
                var bookListDataSource = await GetBookListDataSource.GetBookListAsync();

                this.DefaultViewModel["BookList"] = bookListDataSource;

                // book 1

                //key=nce&bookKey=xingainian1
                var bookOneUnitList = await GetBookUnitListDataSource.GetBookUnitListAsync(key : "nce", bookKey : "xingainian1");

                this.DefaultViewModel["BookOneUnitList"] = bookOneUnitList;

                var bookTwoUnitList = await GetBookUnitListDataSource.GetBookUnitListAsync(key : "nce", bookKey : "xingainian2");

                this.DefaultViewModel["BookTwoUnitList"] = bookTwoUnitList;

                var bookThreeUnitList = await GetBookUnitListDataSource.GetBookUnitListAsync(key : "nce", bookKey : "xingainian3");

                this.DefaultViewModel["BookThreeUnitList"] = bookThreeUnitList;

                var bookFourUnitList = await GetBookUnitListDataSource.GetBookUnitListAsync(key : "nce", bookKey : "xingainian4");

                this.DefaultViewModel["BookFourUnitList"] = bookFourUnitList;
            }
            catch (Exception)
            {
                failed = true;
            }
            await Helper.HideSystemTrayAsync(originbackgroundColor, originforegroundColor, originopacity);

            if (failed)
            {
                MessageDialog md2 = new MessageDialog(Constants.WININET_E_NAME_NOT_RESOLVED, Constants.NETWORK_CONNECTION);
                await md2.ShowAsync();
            }
        }