数据网格Xamarin UWP问题 - HRESULT E_FAIL已从调用COM组件返回
我正在使用Xamarin.Forms.DataGrid数据网格nuget包。当我在Android手机上运行应用程序时,它会显示网格和数据。但是,当我尝试在UWP上运行完全相同的代码时,它会给我以下例外。数据网格Xamarin UWP问题 - HRESULT E_FAIL已从调用COM组件返回
错误消息:
消息“System.Runtime.InteropServices.COMException:错误HRESULT E_FAIL已经从对COM组件的呼叫在Windows.UI.Xaml.UIElement返回\ r \ n。在Xamarin.Forms.Platform.UWP.VisualElementRenderer中测量(大小availableSize)\ r \ n
2.MeasureOverride(Size availableSize)\r\n at Windows.UI.Xaml.UIElement.Measure(Size availableSize)\r\n at Xamarin.Forms.Platform.UWP.VisualElementRenderer
2.MeasureOverride(Size availableSize)\ r \ n at Windows.UI.Xaml.UIElement.Measure(Size availableSize)\ r \ n at Xamarin.Forms.Plat“字符串。
它会显示一个空的网格和列只是UWP很好,如果我注释掉
dgReceipts.ItemsSource = tempList;
,所以我不认为它可能是一个XAML问题。被用于测试
设备是三星Galaxy S6的Android 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>
这是我得到的数据
名单//Gets transactions for reports page
public async Task<List<x_Transactions>> GetReportTransactions()
{
List<x_Transactions> transactions = await database.Table<x_Transactions>
().ToListAsync();
return transactions;
}
而且它被设置为dg i temssource
public async Task FillGrid()
{
List<x_Transactions> tempList;
newList = await App.Database.GetReportTransactions();
dgReceipts.ItemsSource = tempList;
}
不能在Xamarin.UWP
平台使用嵌套滚动。 DataGrid
组件使用ListView
里面。父母不能有ScrollView
。
我用'dgReceipts.ItemsSource = new List- ()'设置了DataGrid的项目源,它工作的很好。你有没有试过打印'tempList'? –
我可以看到正确的数据量正在调试模式下返回,并且它也显示了Android中的正确数据。 –
请尝试清理解决方案并卸载应用程序,然后重新生成项目。 –