首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >UWP滚动期间未关闭的AutoSuggestBox建议列表

UWP滚动期间未关闭的AutoSuggestBox建议列表
EN

Stack Overflow用户
提问于 2019-11-05 08:49:51
回答 1查看 75关注 0票数 0

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

我测试过的一个简单的AutoSuggestBox

代码语言:javascript
运行
复制
<AutoSuggestBox TextChanged="AutoSuggestBox_TextChanged" Width="300" />

是否有比使用ScrollViewer.ViewChanged更好的方法来修复这个问题?

EN

Stack Overflow用户

回答已采纳

发布于 2019-11-05 10:23:39

UWP滚动期间未关闭的

AutoSuggestBox建议列表

我们不能将弹出IsLightDismissEnabled设置为true,这将导致弹出窗口无法显示内容稳定。我检查您的屏幕截图,您可以为ShouldConstrainToRootBounds设置Pupup控件,以避免列表超出界限。

代码语言:javascript
运行
复制
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;
}
票数 0
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58707561

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档