AutoSuggestBox
建议列表在滚动过程中没有关闭,这会导致怪异的UI问题。该问题看起来像下面的问题,我是从默认的 XAML控件库应用程序中提取的。
我已经测试过一个简单的AutoSuggestBox
<AutoSuggestBox TextChanged="AutoSuggestBox_TextChanged" Width="300" />
除了使用 ScrollViewer.ViewChanged
在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;
}