C# 4.0 我正在做一个UWP应用程序,我找到了searchbox,但没有找到Autosuggestbox来发送查询并将Combobox绑定到搜索结果?
如何更新查询并将搜索结果更新回集合 您可以使用事件来处理查询操作。使用此事件内的搜索结果更新您的收藏 简单代码如下:C# 4.0 我正在做一个UWP应用程序,我找到了searchbox,但没有找到Autosuggestbox来发送查询并将Combobox绑定到搜索结果?,c#-4.0,uwp,uwp-xaml,C# 4.0,Uwp,Uwp Xaml,如何更新查询并将搜索结果更新回集合 您可以使用事件来处理查询操作。使用此事件内的搜索结果更新您的收藏 简单代码如下: <Grid Grid.Row="3"> <SearchBox ChooseSuggestionOnEnter="True" FontSize="44 SearchHistoryEnabled="True" PlaceholderText="Select City" SuggestionsRequ
<Grid Grid.Row="3">
<SearchBox ChooseSuggestionOnEnter="True" FontSize="44
SearchHistoryEnabled="True" PlaceholderText="Select City"
SuggestionsRequested="SearchBox_SuggestionsRequested" />
</Grid>
private void mySearchBox\u QuerySubmitted(SearchBox发送方,SearchBox querysubmittedventargs args)
{
ObservableCollection newcollection=新的ObservableCollection{};
字符串querystring=args.QueryText;
foreach(集合中的字符串项)
{
if(项目包含(查询字符串))
{
新建集合。添加(项);
}
}
comsearch.ItemsSource=newcollection;
}
有关SearchBox的更多详细信息,请参考。但根据类的描述,不建议将其用于通用Windows平台(UWP)应用程序
尽管SearchBox是在通用设备系列中实现的,但它在移动设备上并不完全起作用。使用AutoSuggestBox可获得通用搜索体验。看
private void mySearchBox_QuerySubmitted(SearchBox sender, SearchBoxQuerySubmittedEventArgs args)
{
ObservableCollection<string> newcollection = new ObservableCollection<string> { };
string querystring = args.QueryText;
foreach(string item in collection)
{
if(item.Contains(querystring))
{
newcollection.Add(item);
}
}
comsearch.ItemsSource = newcollection;
}