Esempio n. 1
0
        public static IEnumerable <BingResult> GetNewsItems(string query)
        {
            var searchConfig = new BingSearchConfig
            {
                Query     = query,
                QueryType = BingQueryType.Search
            };

            return(BingService.GetAsIncrementalLoading(searchConfig, 50));
        }
Esempio n. 2
0
        private async void SearchButton_OnClick(object sender, RoutedEventArgs e)
        {
            if (!await Tools.CheckInternetConnectionAsync())
            {
                return;
            }

            if (string.IsNullOrEmpty(SearchText.Text))
            {
                return;
            }

            BingCountry  country  = (BingCountry)(CntryList?.SelectedItem ?? BingCountry.UnitedStates);
            BingLanguage language = (BingLanguage)(Languages?.SelectedItem ?? BingLanguage.English);

            BingQueryType queryType;

            switch (QueryType.SelectedIndex)
            {
            case 1:
                queryType = BingQueryType.News;
                break;

            default:
                queryType = BingQueryType.Search;
                break;
            }

            var searchConfig = new BingSearchConfig
            {
                Country   = country,
                Language  = language,
                Query     = SearchText.Text,
                QueryType = queryType
            };

            // Gets an instance of BingService that is able to load search results incrementally.
#pragma warning disable CS0618 // Type or member is obsolete
            var collection = BingService.GetAsIncrementalLoading(searchConfig, 50);
#pragma warning restore CS0618 // Type or member is obsolete
            collection.OnStartLoading = async() => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SampleController.Current.DisplayWaitRing = true; });

            collection.OnEndLoading = async() => await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SampleController.Current.DisplayWaitRing = false; });

            ListView.ItemsSource = collection;
        }