如何解决未检测到已安装的组件元素已经是另一个元素的子元素加载 SearchBox 时出现 UWP 错误
我在加载 SearchBox 时遇到此间歇性错误,但不确定我在这里做错了什么。项目已从 Windows 8.1 应用平台迁移到 UWP。
未检测到已安装的组件。元素已经是 另一个元素。
我在 App.g.i.cs 中收到此错误。任何 CS 文件中都没有抛出异常。 这是代码。页面中有两个 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 举报,一经查实,本站将立刻删除。