简体   繁体   English

How is it correct for display json object in.xaml file using xamarin c# iOS

[英]How is it correct for display json object in .xaml file using xamarin c# iOS

I have one API which display meteo data on.xaml file like that:我有一个 API 显示气象数据 on.xaml 文件,如下所示:

      <Label Text="{Binding Coord.Lon}" 
                   Style="{StaticResource labelResultStyle}"
                   TextColor="White"
                   FontAttributes="Bold"
                   Grid.Row="2"
                   Grid.Column="0"
                   HorizontalOptions="CenterAndExpand"/>

First API object第一个 API object

For the second API I try to Binding Data lile that:对于第二个 API,我尝试绑定数据:

<Label Text="{Binding weatherForecast.MaxTemp}" 
                       Style="{StaticResource labelResultStyle}"
                       FontAttributes="Bold"
                       HorizontalOptions="CenterAndExpand"
                       HorizontalTextAlignment="Start"
                       TextColor="White"/>

There is no result on the display.显示屏上没有结果。

My second Json object look like:我的第二个 Json object 看起来像:

Second API object第二 API object

How should I call the data from the second object in the.xaml file?我应该如何调用.xaml文件中第二个object的数据?

weatherForecast is a collection of objects, so you have to specify which element of the collection you want to use weatherForecast是对象的集合,因此您必须指定要使用集合的哪个元素

Text="{Binding weatherForecast[0].MaxTemp}" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM