AutoSuggestBox建议列表在滚动期间没有关闭,这会导致奇怪的UI问题。这个问题将类似于下面的问题,这是我从默认的XAML控件库应用程序中获取的。

我测试过的一个简单的AutoSuggestBox
<AutoSuggestBox TextChanged="AutoSuggestBox_TextChanged" Width="300" />是否有比使用ScrollViewer.ViewChanged更好的方法来修复这个问题?
发布于 2019-11-05 10:23:39
UWP滚动期间未关闭的
AutoSuggestBox建议列表
我们不能将弹出IsLightDismissEnabled设置为true,这将导致弹出窗口无法显示内容稳定。我检查您的屏幕截图,您可以为ShouldConstrainToRootBounds设置Pupup控件,以避免列表超出界限。
private void AutoSuggestBox_Loaded(object sender, RoutedEventArgs e)
{
var popup = MyFindGridViewChildByName(sender as AutoSuggestBox, "SuggestionsPopup") as Popup;
popup.ShouldConstrainToRootBounds = true;
}
public static DependencyObject MyFindGridViewChildByName(DependencyObject parant, string ControlName)
{
int count = VisualTreeHelper.GetChildrenCount(parant);
for (int i = 0; i < count; i++)
{
var MyChild = VisualTreeHelper.GetChild(parant, i);
if (MyChild is FrameworkElement && ((FrameworkElement)MyChild).Name == ControlName)
return MyChild;
var FindResult = MyFindGridViewChildByName(MyChild, ControlName);
if (FindResult != null)
return FindResult;
}
return null;
}https://stackoverflow.com/questions/58707561
复制相似问题