Beispiel #1
0
        private async void searchPane_SuggestionsRequested(SearchPane sender,
                                                           SearchPaneSuggestionsRequestedEventArgs args)
        {
            if (args.QueryText.Length >= 2)
            {
                var linkService = ServiceLocator.Current.GetInstance <ILinkService>();
                SearchPaneSuggestionsRequestDeferral deferral = args.Request.GetDeferral();
                List <Link> results = await linkService.Search(args.QueryText);

                List <string> searchResults = results.Select(s => s.Name).ToList();
                args.Request.SearchSuggestionCollection.AppendQuerySuggestions(searchResults);
                deferral.Complete();
            }
        }
Beispiel #2
0
        private async void SearchPaneSuggestionsRequested(
            SearchPane sender,
            SearchPaneSuggestionsRequestedEventArgs args)
        {
            SearchPaneSuggestionsRequestDeferral deferral = args.Request.GetDeferral();

            GeocodeRequestOptions requests = new GeocodeRequestOptions(args.QueryText);

            _searchManager  = MapView.SearchManager;
            _searchResponse = await _searchManager.GeocodeAsync(requests);

            foreach (GeocodeLocation locationData in _searchResponse.LocationData)
            {
                args.Request.SearchSuggestionCollection.AppendQuerySuggestion(locationData.Address.FormattedAddress);
            }

            deferral.Complete();
        }