我正在使用XAMARIN应用程序。我打电话打开天气API,并能够获得JSON响应。如何通过调用Openweather API在xamarin中显示天气图标?
在字符串格式之后,我可以在标题(标题)中显示城市名称+温度。
仍然我不能绑定图像图标。
无论绑定图像在内容页面中,还是在标题上都不起作用。
这段语法来自我的标签主页..它调用城市标签页。
<NavigationPage Title="City" Icon="city.png">
<x:Arguments>
<local:CityPage />
</x:Arguments>
</NavigationPage>
并在city.xaml.cs中 - 我打电话给这个方法。
public async void GetWeather()
{
Weather weather = await Core.GetWeather("07004");
if (weather != null)
{
this.BindingContext = weather;
string sWeather = String.Format("{0}°F", weather.Temperature);
this.Title = weather.Title + " " + sWeather;
}
}
图片图标具有来在该温度下的端部。
请发表您的XAML /代码中的相关部分,所以我们可以看到你已经在做什么 – Jason