/// <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)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var BookDataGroups = BreedDataSource.GetGroups((String)navigationParameter);

            this.DefaultViewModel["Groups"] = BookDataGroups;
        }
示例#2
0
        //Providing search suggestions - creates a self populated list from the dogs.txt file
        void OnSuggestionsRequested(SearchPane sender, SearchPaneSuggestionsRequestedEventArgs args)
        {
            Dictionary <string, List <BreedDataItem> > _results = new Dictionary <string, List <BreedDataItem> >();
            List <string> termList = new List <string>();
            var           groups   = BreedDataSource.GetGroups("AllGroups");
            string        query    = args.QueryText.ToLower();
            var           all      = new List <BreedDataItem>();

            _results.Add("All", all);

            foreach (var group in groups)
            {
                var items = new List <BreedDataItem>();
                _results.Add(group.ShortTitle, items);

                foreach (var item in group.Items)
                {
                    termList.Add(item.ShortTitle.ToLower());
                }
            }
            foreach (var term in termList)
            {
                if (term.StartsWith(query.ToLower()))
                {
                    args.Request.SearchSuggestionCollection.AppendQuerySuggestion(term);
                }
            }
        }
        /// <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)
        {
            var queryText = navigationParameter as String;

            // TODO: Application-specific searching logic.  The search process is responsible for
            //       creating a list of user-selectable result categories:
            //
            //       filterList.Add(new Filter("<filter name>", <result count>));
            //
            //       Only the first filter, typically "All", should pass true as a third argument in
            //       order to start in an active state.  Results for the active filter are provided
            //       in Filter_SelectionChanged below.

            var filterList = new List <Filter>();

            filterList.Add(new Filter("All", 0, true));

            var    groups = BreedDataSource.GetGroups("AllGroups");
            string query  = queryText.ToLower();
            var    all    = new List <BreedDataItem>();

            _results.Add("All", all);

            foreach (var group in groups)
            {
                var items = new List <BreedDataItem>();

                _results.Add(group.Title, items);

                foreach (var item in group.Items)
                {
                    if (item.Title.ToLower().Contains(query) || item.Description.ToLower().Contains(query))
                    {
                        all.Add(item);
                        items.Add(item);
                    }
                }
                filterList.Add(new Filter(group.Title, items.Count, false));
            }
            filterList[0].Count = all.Count;

            // Communicate results through the view model
            this.DefaultViewModel["QueryText"]   = '\u201c' + queryText + '\u201d';
            this.DefaultViewModel["Filters"]     = filterList;
            this.DefaultViewModel["ShowFilters"] = filterList.Count > 1;
        }