我使用AutoSuggestBox
使用找到的样式here进行分组支持,但我在移动设备上显示建议弹出窗口时遇到了一个奇怪的问题(在桌面上)是100%罚款,我可以看到弹出窗口内的分组列表。
当我在AutoSuggestBox
中写字时,会显示一个错误定位的未分组弹出窗口,如您所见:
这一直持续到我选择其中一个项目,但选择通过显示正确的弹出窗口提供更奇怪的结果,即使它在选择项目之前使用我所拥有的文本进行过滤。
您可以在桌面上看到正确的行为:
<AutoSuggestBox Style="{StaticResource GroupedAutoSuggestBoxStyle}"
UpdateTextOnSelect="True"
TextMemberPath="Name"
VerticalAlignment="Center"
ItemsSource="{x:Bind ServicesCollectionViewSource.View, Mode=OneWay}"
TextChanged="ServicesFilterAutoSuggestBox_OnTextChanged"
QuerySubmitted="ServicesFilterAutoSuggestBox_OnQuerySubmitted"
LostFocus="ServicesFilterAutoSuggestBox_OnLostFocus"
AutoMaximizeSuggestionArea="True"
Grid.Column="1">
...
private void ServicesFilterAutoSuggestBox_OnTextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args)
{
if (args.Reason != AutoSuggestionBoxTextChangeReason.UserInput) return;
if (string.IsNullOrEmpty(sender.Text) && ViewModel.AccountService != null)
{
// User canceled previous selection, so we reset it
ViewModel.AccountService = null;
}
// Filter the results
ServicesCollectionViewSource.Source = from services
in ViewModel.Services
where services.Name.ToLowerInvariant().Contains(sender.Text.ToLowerInvariant())
group services by services.Section.Id;
}
private void ServicesFilterAutoSuggestBox_OnQuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args)
{
if (args.ChosenSuggestion != null)
{
ViewModel.AccountService = (Service) args.ChosenSuggestion;
}
else
{
ViewModel.AccountService = null;
}
}
我不明白为什么它在桌面上工作正常,而它在移动设备上有这种奇怪的行为,我真的需要你的帮助。