【发布时间】:2018-04-24 16:53:53
【问题描述】:
我已经从 xamarin 表单中消费了休息服务。但我的列表视图没有显示出来。它只显示了很多空行。
休息服务响应
[
{
"prodName":"abc",
"qty":142.0,
"price":110.0
},
{
"prodName":"efg",
"qty":20.0,
"price":900.0
}
]
我的 .xaml 文件
<ListView x:Name="ProductsListView">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout Orientation="Horizontal">
<Label Text="{Binding prodName}" TextColor="Black"></Label>
<Label Text="{Binding price}" TextColor="Black"></Label>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
xaml.cs 文件
private async void GetProducts()
{
HttpClient client = new HttpClient();
var response = await client.GetStringAsync("http://myUrl/Api/Values");
var products = response;
ProductsListView.ItemsSource = products;
}
【问题讨论】:
标签: c# xaml xamarin xamarin.forms