【问题标题】:AutoSuggestBox is not working properly in windows phone 8.1 runtime appAutoSuggestBox 在 windows phone 8.1 运行时应用程序中无法正常工作
【发布时间】:2015-02-16 23:46:28
【问题描述】:

我在 windows phone 8(Silverlight 应用程序)中使用了 AutoCompleteBox,它运行良好,但在 autosuggestbox 中我找不到 ItemFilter 属性,即使我使用 TextChanged 事件它也没有给出相关建议。我的代码如下。

Xaml 代码:

    <AutoSuggestBox x:Name="suggestions" HorizontalAlignment="Left" Margin="52,62,0,0" 
ItemsSource="{Binding }" VerticalAlignment="Top" 
Width="296" TextChanged="suggestions_TextChanged" 
SuggestionChosen="suggestions_SuggestionChosen"/>

C#代码:

protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            suggestions.ItemsSource = Suggestions;
        }


        private void suggestions_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
        {
            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
            {
                Suggestions.Clear();

                Suggestions.Add("Nambukarthy Raveendran");
                Suggestions.Add("Jeyanthan Periyasami");
                Suggestions.Add("Vijay Selvamm");
                Suggestions.Add("Ashraf Ali");

                List<string> myList = new List<string>();
                foreach (string myString in Suggestions)
                {
                    if (myString.Contains(sender.Text) == true)
                    {
                        myList.Add(myString);
                    }
                }
                sender.ItemsSource = myList;

            }
        }

        private void suggestions_SuggestionChosen(AutoSuggestBox sender, AutoSuggestBoxSuggestionChosenEventArgs args)
        {
            suggestions.Text = "Choosen";
        }

提前致谢:)

【问题讨论】:

    标签: windows-phone-8 windows-phone-8.1


    【解决方案1】:

    尝试在TextChanged 事件中添加您想要的建议:

    Strange results in AutoSuggestBox in Windows Phone 8.1,可以帮到你。

    Reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多