如何在Windows 8中创建自动完成搜索文本框

时间:2013-01-11 15:16:07

标签: c# search windows-8 autocomplete bing

我发现Windows 8文本框有一个属性“IsPredictionEnabled”。据我所知,它用于启用自动完成功能。但即使使用软键盘,设置此属性也无效。

如果我希望此搜索文本框能够搜索bing并检索与搜索查询相对应的一些图像,那该怎么办呢?

谢谢,

1 个答案:

答案 0 :(得分:0)

最好使用像这样的cutom控件:

AutoCompleteBoxWinRT

从bing获取搜索结果您需要使用bind api:

Bing API

使用AutCompleteBoxWinRT:

导入命名空间:

 xmlns:ab="using:AutoCompleteBox"

放置控件:

  <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
    <ab:AutoCompleteBox Name="ABBox" Text="{Binding Text, Mode=TwoWay}" WatermarkText="Type something" />

    <Button Content="Test" VerticalAlignment="Top" Margin="0,100,0,0" Command="{Binding TestCommand}" />
</Grid>

此处您可以下载示例应用:LINK