微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

未检测到已安装的组件元素已经是另一个元素的子元素加载 SearchBox 时出现 UWP 错误

如何解决未检测到已安装的组件元素已经是另一个元素的子元素加载 SearchBox 时出现 UWP 错误

我在加载 SearchBox 时遇到此间歇性错误,但不确定我在这里做错了什么。项目已从 Windows 8.1 应用平台迁移到 UWP。

未检测到已安装的组件。元素已经是 另一个元素。

我在 App.g.i.cs 中收到此错误。任何 CS 文件中都没有抛出异常。

enter image description here

这是代码页面中有两个 SearchBox 元素,我想知道这是否可能是问题所在。

                <TextBlock 
                    Visibility="{
                        Binding ServiceReview.ServiceReviewType_Id,Converter={StaticResource ConsumerTypetoVisibleConverter},Mode=OneWay
                    }"
                    Style="{StaticResource FormTextBlock}"
                    Text="Individual's Name"/>
                <SearchBox 
                    Visibility="{
                        Binding ServiceReview.ServiceReviewType_Id,Mode=OneWay
                    }"
                    x:Name="IndividualSearchBox"
                    Style="{StaticResource FormSearchBox}"
                    PlaceholderText="Search by Individual's Name"
                    SuggestionsRequested="IndividualSearchBox_OnSuggestionsRequested"
                    ResultSuggestionChosen="IndividualSearchBox_OnResultSuggestionChosen"
                    SearchHistoryEnabled="False">
                </SearchBox>
 
                    <TextBlock
                                Style="{StaticResource FormTextBlock}"
                                Text="Search Team Members To Add"/>
                    <SearchBox
                                x:Name="UserSearchBox"
                                Style="{StaticResource FormSearchBox}"
                                PlaceholderText="Search by Team Member's Name"
                                SuggestionsRequested="UserSearchBox_OnSuggestionsRequested"
                                ResultSuggestionChosen="UserSearchBox_OnResultSuggestionChosen"
                        SearchHistoryEnabled="False">
                    </SearchBox>

用户搜索框给出了错误

我们像这样加载数据:

 private async void UserSearchBox_OnSuggestionsRequested(SearchBox sender,SearchBoxSuggestionsRequestedEventArgs args)
    {
        try
        {

       
        if (string.IsNullOrEmpty(args.QueryText))
        {
            return;
        }

        var collection = args.Request.SearchSuggestionCollection;

        if (_oldUserQuery == args.QueryText) return;

        var deferral = args.Request.GetDeferral();

        List<Employee> employees = await _employeeService.SearchEmployees(args.QueryText);

        foreach (var employee in employees)
        {
            collection.AppendResultSuggestion(employee.FullName,string.Empty,employee.EmployeeId.ToString(),RandomAccessstreamReference.CreateFromUri(
                new Uri("http://www.dotnettoscana.org/logo.png")),string.Empty);
        }

        deferral.Complete();

        _oldUserQuery = args.QueryText;
        }
        catch (Exception ex)            {

            throw;
        }
    }

这里是与控件相关的样式。

<Style targettype="SearchBox" x:Key="FormSearchBox">
        <Setter Property="Height" Value="55"/>
        <!--<Setter Property="SearchHistoryEnabled" Value="False"/>-->
        <Setter Property="Margin" Value="20,15"/>
        <Setter Property="HorizontalAlignment" Value="Left"/>
        <Setter Property="Width" Value="380" />
        <!--Testing by moving below contents from SearchBox-->
        <Setter Property="VerticalAlignment" Value="Top"/>
        <Setter Property="Padding" Value="{StaticResource MediumThickness}"/>
        <Setter Property="BorderBrush" Value="{StaticResource BorderBrushColor}"/>
        <Setter Property="BorderThickness" Value="{StaticResource BorderThickness}"/>
        <Setter Property="FontSize" Value="{StaticResource AppFontSize}"/>
    </Style>

任何有关发现问题的指示将不胜感激。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?