/// <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 sampleDataGroups = RecipeDataSource.GetGroups((String)navigationParameter);

            this.DefaultViewModel["Groups"] = sampleDataGroups;
        }
        /// <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));

            // Search recipes and tabulate results
            var    groups = RecipeDataSource.GetGroups("AllGroups");
            string query  = queryText.ToLower();
            var    all    = new List <RecipeDataItem>();

            _results.Add("All", all);

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

                foreach (var item in group.Items)
                {
                    if (item.Title.ToLower().Contains(query) || item.Directions.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;
        }
Esempio n. 3
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)
        {
            var queryText = navigationParameter as String;

            // TODO: Application-specific searching logic.  The search process is responsible for
            //       사용자가 선택할 수 있는 결과 범주 목록을 만듭니다.
            //
            //       filterList.Add(new Filter("<filter name>", <result count>));
            //
            //       활성 상태에서 시작하려면 첫 번째 필터(일반적으로 "모두")만 세 번째 인수로 true를
            //       전달해야 합니다. 활성 필터의 결과가 아래의
            //       Filter_SelectionChanged에 제공됩니다.

            var filterList = new List <Filter>();

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

            // Search recipes and tabulate results
            var    groups = RecipeDataSource.GetGroups("AllGroups");
            string query  = queryText.ToLower();
            var    all    = new List <RecipeDataItem>();

            _results.Add("All", all);

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

                foreach (var item in group.Items)
                {
                    if (item.Title.ToLower().Contains(query) || item.Directions.ToLower().Contains(query))
                    {
                        all.Add(item);
                        items.Add(item);
                    }
                }

                filterList.Add(new Filter(group.Title, items.Count, false));
            }

            filterList[0].Count = all.Count;
            // 뷰 모델을 통해 결과를 전달합니다.
            this.DefaultViewModel["QueryText"]   = '\u201c' + queryText + '\u201d';
            this.DefaultViewModel["CanGoBack"]   = this._previousContent != null;
            this.DefaultViewModel["Filters"]     = filterList;
            this.DefaultViewModel["ShowFilters"] = filterList.Count > 1;
        }