Example #1
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="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>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            //  Create the datasource for the Books.
            var libraryBooks = LibraryDataSource.GetBooks();

            this.DefaultViewModel["Items"] = libraryBooks;

            //  Create the datasource for the Searches binding.
            var searches = LibraryDataSource.GetSearches();

            this.DefaultViewModel["Searches"] = searches;

            //  Create the datasource for the CurrentSearch.
            var currentSearch = LibraryDataSource.GetCurrentSearch();

            this.DefaultViewModel["Current"] = currentSearch;
        }
Example #2
0
        /// <summary>
        /// Handles the Checked event for the group of radio buttons on the page
        /// </summary>
        /// <param name="sender">The RadioButton that raised the event</param>
        /// <param name="e">The args for the event</param>
        private void SelectSortSequence(object sender, RoutedEventArgs e)
        {
            //  Don't process anything if the datamodel is not initialised, things are being loaded.
            if (this.DefaultViewModel.Count() == 0)
            {
                return;
            }

            //  The button is names according to the enumeration.
            BookSortEnum seq = (BookSortEnum)Enum.Parse(typeof(BookSortEnum), (sender as RadioButton).Name);

            //  Set the current sort sequence
            LibraryDataSource.SetSortSequence(seq);
            //  retrieve the books sorted accordingly
            var books = LibraryDataSource.GetBooks();

            this.DefaultViewModel["Items"] = books;
        }