protected override void OnNavigatedTo()

in SampleGallery/Pages/SearchResultsPage.xaml.cs [42:80]


        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);

            var searchText = (string)e.Parameter;

            // Name matches
            var nameMatches = from sampleDef in SampleDefinitions.Definitions
                          where sampleDef.DisplayName.IndexOf(searchText, StringComparison.CurrentCultureIgnoreCase) >= 0
                          select sampleDef;

            // Tag matches
            var tagMatches = from sampleDef in SampleDefinitions.Definitions
                          where (sampleDef.Tags != null && sampleDef.Tags.Any(str => str.IndexOf(searchText, StringComparison.CurrentCultureIgnoreCase) >= 0))
                          select sampleDef;

            HeaderTextBlock.Text = "Results for '" + searchText + "':";
            MatchingTitleSampleList.SetHeaderText("Matches by Name (" + nameMatches.Count() + ")");
            MatchingTagSampleList.SetHeaderText("Matches by Tag (" + tagMatches.Count() + ")");
            if (nameMatches.Count() > 0)
            {
                MatchingTitleSampleList.SetNoContentTextVisibility(false);
                MatchingTitleSampleList.ItemsSource = nameMatches.OrderByDescending(i => i.DisplayName.StartsWith(searchText, StringComparison.CurrentCultureIgnoreCase)).ThenBy(i => i.DisplayName);
            }
            else
            {
                MatchingTitleSampleList.SetNoContentTextVisibility(true);
            }

            if (tagMatches.Count() > 0)
            {
                MatchingTagSampleList.SetNoContentTextVisibility(false);
                MatchingTagSampleList.ItemsSource = tagMatches.OrderByDescending(i => i.DisplayName.StartsWith(searchText, StringComparison.CurrentCultureIgnoreCase)).ThenBy(i => i.DisplayName);
            }
            else
            {
                MatchingTagSampleList.SetNoContentTextVisibility(true);
            }
        }