Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 4.0 我正在做一个UWP应用程序,我找到了searchbox,但没有找到Autosuggestbox来发送查询并将Combobox绑定到搜索结果?_C# 4.0_Uwp_Uwp Xaml - Fatal编程技术网

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;
 }