/// <summary> /// 更新搜索提示 /// </summary> private void UpdateSearchSuggest(string para) { if (Suggests == null) { Suggests = new ObservableCollection <string>(); } SearchPanelVisibility = Visibility.Collapsed; Suggests.Clear(); if (string.IsNullOrEmpty(para)) { return; } Func <string, List <string> > suggests = SearchApi.GetKeySuggest; suggests.BeginInvoke(para, (ar => { var resu = suggests.EndInvoke(ar); if (resu.Any()) { DispatcherHelper.CheckBeginInvokeOnUI((() => { if (resu.Count > 15) { var sds = resu.Take(15); Suggests.AddRange(sds); } else { Suggests.AddRange(resu); } SearchPanelVisibility = Visibility.Visible; })); } }), null); }
private async void UpdateSuggests(string q) { string query = string.Format(GlobFuncs.getConfig("serviceAutoComplit"), GlobFuncs.getConfig("token"), q); internet = new OnlineStreem(query, log); await internet.PostCallAPI(); internet.getAddress(); Suggests.Clear(); foreach (var l in internet.getAddress()) { Suggests.Add(l); } this.machine.Fire(ViewTrigger.SelectPlaceOnMap); }