Windows phone 8 windows phone 8.1中的自动完成文本框

Windows phone 8 windows phone 8.1中的自动完成文本框,windows-phone-8,windows-phone,windows-phone-8.1,Windows Phone 8,Windows Phone,Windows Phone 8.1,我想在我的windows phone 8.1应用程序中添加一些功能,让我的用户输入一些字符,然后我向他推荐一些单词 public IEnumerable AutoCompletions = new List<string>() { "Lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit", "Nullam", "felis", "dui", "gravida", "at"}; 公共I

我想在我的windows phone 8.1应用程序中添加一些功能,让我的用户输入一些字符,然后我向他推荐一些单词

public IEnumerable AutoCompletions = new List<string>()
{
 "Lorem", "ipsum", "dolor", "sit", "amet", "consectetur", "adipiscing", "elit", "Nullam", "felis", "dui", "gravida", "at"};
公共IEnumerable自动完成=新列表() { “Lorem”、“ipsum”、“dolor”、“sit”、“amet”、“Concertetur”、“Adipising”、“elit”、“Nullam”、“felis”、“dui”、“gravida”、“at”}; 例如,用户输入“a”,我建议“amet”、“at”和“adipising”,进一步用户输入“am”,我建议“amet”。
请帮助我

您要做的是仅显示适用于给定输入的建议。不是所有可能的字符串

假设您有以下AutoSuggestBox:

<AutoSuggestBox 
   TextChanged="AutoSuggestBox_TextChanged"
   SuggestionChosen="AutoSuggestBox_SuggestionChosen">
    <AutoSuggestBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding}" />
            </StackPanel>
        </DataTemplate>
    </AutoSuggestBox.ItemTemplate>
</AutoSuggestBox>

以下是事件处理程序:

private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
    {
        if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
        {
            // You can set a threshold when to start looking for suggestions
            if (sender.Text.Length > 3)
            {
                sender.ItemsSource = getSuggestions(sender.Text); 
            }
            else {
                sender.ItemsSource = new List<String> { };
            }
        }
    }
private void AutoSuggestBox\u TextChanged(AutoSuggestBox发送方、autosuggestboxtextchangedventargs args)
{
if(args.Reason==AutoSuggestionBoxTextChangeReason.UserInput)
{
//您可以设置开始查找建议的阈值
如果(sender.Text.Length>3)
{
sender.ItemsSource=getSuggestions(sender.Text);
}
否则{
sender.ItemsSource=新列表{};
}
}
}

您所要做的就是编写一个
getSuggestions(String text)
方法,返回给定输入的合理建议。

您要做的是只显示适用于给定输入的建议。不是所有可能的字符串

假设您有以下AutoSuggestBox:

<AutoSuggestBox 
   TextChanged="AutoSuggestBox_TextChanged"
   SuggestionChosen="AutoSuggestBox_SuggestionChosen">
    <AutoSuggestBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding}" />
            </StackPanel>
        </DataTemplate>
    </AutoSuggestBox.ItemTemplate>
</AutoSuggestBox>

以下是事件处理程序:

private void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
    {
        if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
        {
            // You can set a threshold when to start looking for suggestions
            if (sender.Text.Length > 3)
            {
                sender.ItemsSource = getSuggestions(sender.Text); 
            }
            else {
                sender.ItemsSource = new List<String> { };
            }
        }
    }
private void AutoSuggestBox\u TextChanged(AutoSuggestBox发送方、autosuggestboxtextchangedventargs args)
{
if(args.Reason==AutoSuggestionBoxTextChangeReason.UserInput)
{
//您可以设置开始查找建议的阈值
如果(sender.Text.Length>3)
{
sender.ItemsSource=getSuggestions(sender.Text);
}
否则{
sender.ItemsSource=新列表{};
}
}
}

您所要做的就是编写一个
getSuggestions(String text)
方法,为给定的输入返回合理的建议。

据我所知,它仍然不适用于
WP8.1
!真正地在市场上,我看到了许多使用此功能的应用程序。据我所知,您可能不了解示例,它仍然不适用于
WP8.1
!真正地在市场上,我看到很多应用程序都有这个特点,也许你们不明白,比如,可能帮助其他用户,可能帮助其他用户