/// <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; }
/// <summary> /// Handles the selection Changed event for the drop down list of saved searches. /// </summary> /// <param name="sender">Instance of the cbSelectSearch drop down box.</param> /// <param name="e"></param> private void cbSelectSearch_SelectionChanged(object sender, SelectionChangedEventArgs e) { // Try setting the selected search type for the current search (SelectedSearchTypeIndex) if (e.AddedItems.Count() == 1) { // TODO: Refactor some of this to a New SearchViewModel constructor or Factory (IN the LibraryDataSource (the View Model) // Retrieve the curent search, ready for update. // must add to a collection, with only 1 item, to avoid an exception. var currentSearch = LibraryDataSource.GetCurrentSearch(); // Get the selected search from the drop down. var selectedSearch = (SearchViewModel)e.AddedItems[0]; // Get the available SearchTypes. var searchTypes = LibraryDataSource.GetSearchTypes(); // Update the CurrentSearch with the selected search. currentSearch.First().SetSearch(selectedSearch, searchTypes); } }
/// <summary> /// Handles the OnNewSearchButtonClicked even from the app bar button /// </summary> /// <param name="sender">Instance of the App Bar button</param> /// <param name="e">Instance of the event args.</param> private void OnNewSearchButtonClicked(object sender, RoutedEventArgs e) { // TODO: Refactor some of this to a New SearchViewModel constructor or Factory (IN the LibraryDataSource (the View Model) // Reset the setting in the CurrentSearchViewer. // 1 Blank Search String // 2 Search Types to "Select a search Type......" // 3 Searchable Values to empty var currentSearch = LibraryDataSource.GetCurrentSearch(); var searchTypes = LibraryDataSource.GetSearchTypes(); var selectedSearch = new SearchViewModel() { UniqueId = string.Empty, Type = searchTypes[0].Type, SearchString = string.Empty, SearchDate = DateTime.Now.ToString(), }; currentSearch.First().SetSearch(selectedSearch, searchTypes); }
/// <summary> /// Handles the OnSaveSearchButtonClicked event from the app bar button /// </summary> /// <param name="sender">Instance of the App Bar button</param> /// <param name="e">Instance of the event args.</param> private void OnSaveSearchButtonClicked(object sender, RoutedEventArgs e) { LibraryDataSource.AddSearch(LibraryDataSource.GetCurrentSearch().First()); }