XAML AutoSuggestionBox如何显示没有搜索结果的单词

问题描述

我一直在尝试显示句子的方式,如果AutoSuggestionBox下拉菜单中没有显示建议,它将在下拉菜单显示“无建议”,并且在下拉菜单中获得新建议时会消失

前面的XAML代码没什么特别的

 <AutoSuggestBox PlaceholderText="What do you want to eat?" QueryIcon="Find" Name="MainSearchBar"
                TextChanged="AutoSuggestBox_TextChanged"
                QuerySubmitted="AutoSuggestBox_QuerySubmitted"
                SuggestionChosen="AutoSuggestBox_SuggestionChosen" Grid.ColumnSpan="3" Height="38" Margin="47,42,187,0"/>

XAML CS代码

  private void AutoSuggestBox_TextChanged(AutoSuggestBox sender,AutoSuggestBoxTextChangedEventArgs args)
        {
            WarningPopup.IsOpen = false;

        if (sender.Text.Length > 2)
            {

            if (args.Reason == AutoSuggestionBoxTextChangeReason.UserInput)
                {
                    
                    suggestionListTest = _nameList.Where(x => x.StartsWith(sender.Text)).ToList();
                    sender.ItemsSource = suggestionListTest;
                }
            }
        else
            {
                sender.ItemsSource = new string[] { "No Suggestions Available" };
            }
        }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)