RositsaV
RositsaV

Reputation: 101

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:

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

First API object

For the second API I try to Binding Data lile that:

<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:

Second API object

How should I call the data from the second object in the .xaml file ?

Upvotes: 0

Views: 35

Answers (1)

Jason
Jason

Reputation: 89179

weatherForecast is a collection of objects, so you have to specify which element of the collection you want to use

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

Upvotes: 1

Related Questions