C# 数据网格Xamarin UWP问题-调用COM组件返回HRESULT E_FAIL
我正在使用Xamarin.Forms.DataGrid数据网格nuget包。当我在安卓手机上运行应用程序时,它会显示网格和数据。然而,当我尝试在UWP上运行完全相同的代码时,它会给我以下异常 错误消息: 消息“System.Runtime.InteropServices.COMException:调用COM组件时返回错误HRESULT E\u FAIL。\r\n位于Windows.UI.Xaml.UIElement.Measure(Size availableSize)\r\n位于Xamarin.Forms.Platform.UWP.VisualElementRendererC# 数据网格Xamarin UWP问题-调用COM组件返回HRESULT E_FAIL,c#,android,uwp,xamarin.forms,xamarin.uwp,C#,Android,Uwp,Xamarin.forms,Xamarin.uwp,我正在使用Xamarin.Forms.DataGrid数据网格nuget包。当我在安卓手机上运行应用程序时,它会显示网格和数据。然而,当我尝试在UWP上运行完全相同的代码时,它会给我以下异常 错误消息: 消息“System.Runtime.InteropServices.COMException:调用COM组件时返回错误HRESULT E\u FAIL。\r\n位于Windows.UI.Xaml.UIElement.Measure(Size availableSize)\r\n位于Xamarin
2.MeasureOverride(Size availableSize)\r\n位于Windows.UI.Xaml.UIElement.Measure(Size availableSize)\r\n位于Xamarin.Forms.Platform.UWP.VisualElementRenderer
2.MeasureOverride(Size availableSize)\r\n位于Windows.UI.Xaml.UIElement.Measure(Size availableSize)\r\n位于Xamarin.Forms.Plat“字符串
如果我注释掉,它将在UWP中显示空的网格和列
DGReceives.ItemsSource=tempList代码>
所以我认为这不可能是XAML的问题
用于测试的设备是三星Galaxy S6安卓7.0和Lumia 640
谢谢你的帮助
XAML代码
<dg:DataGrid x:Name="dgReceipts" RowHeight="70" HeaderHeight="50" BorderColor="#CCCCCC" HeaderBackground="#E0E6F8">
<dg:DataGrid.Columns>
<dg:DataGridColumn Title="ID" Width="1*">
<dg:DataGridColumn.CellTemplate>
<DataTemplate>
<ContentView>
<Label Text="{Binding Apar_ID}" VerticalOptions="Center"
HorizontalOptions="Center"/>
</ContentView>
</DataTemplate>
</dg:DataGridColumn.CellTemplate>
</dg:DataGridColumn>
</dg:DataGrid.Columns>
<dg:DataGrid.RowsBackgroundColorPalette>
<dg:PaletteCollection>
<Color>#F2F2F2</Color>
<Color>#FFFFFF</Color>
</dg:PaletteCollection>
</dg:DataGrid.RowsBackgroundColorPalette>
</dg:DataGrid>
#F2F2F2
#FFFFFF
这是我得到数据列表的地方
//Gets transactions for reports page
public async Task<List<x_Transactions>> GetReportTransactions()
{
List<x_Transactions> transactions = await database.Table<x_Transactions>
().ToListAsync();
return transactions;
}
//获取报表页面的事务
公共异步任务GetReportTransactions()
{
列表事务=等待数据库.Table
().ToListAsync();
退货交易;
}
以及它设置到dg itemssource的位置
public async Task FillGrid()
{
List<x_Transactions> tempList;
newList = await App.Database.GetReportTransactions();
dgReceipts.ItemsSource = tempList;
}
public异步任务FillGrid()
{
圣殿骑士名单;
newList=wait App.Database.GetReportTransactions();
DGReceives.ItemsSource=模板列表;
}
您不能在Xamarin.UWP
平台中使用嵌套滚动<代码>数据网格
组件在内部使用列表视图
。它不能有ScrollView
parent。我已经用dReceipts.ItemsSource=new List()
设置了DataGrid
的项目源,它工作得很好。您是否尝试打印tempList
?我可以看到在调试模式下返回了正确数量的数据,并且它在Android中也显示了正确的数据。请尝试清理解决方案并卸载应用程序,再次重建项目。当我尝试在UWP上打开页面时,仍然会出现相同的异常。我将继续尝试修复它,如果我不修复,我将稍后在这里发布更多代码。正如您所说,这不是xaml问题。你试过更新你的xamarin.forms版本吗?哇。那真的很臭。你知道github有这张票吗?或者有什么可以解决的吗?在iOS中运行良好,Android在这里不起作用。在很多情况下,您希望有一个完全展开的列表视图,下面的内容可以滚动。