设为首页 加入收藏

TOP

Win10 UWP 开发学习代码(不断更新)(二)
2017-10-11 16:07:13 】 浏览:5385
Tags:Win10 UWP 开发 学习 代码 不断 更新
rt.DeserializeObject<Info>(WeatherJson); this.DataContext = i;

天气信息 Info Class

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Weather
{
  public  class Info
    {
        public int error { get; set; }
        public string status { get; set; }
        public string date { get; set; }
        public List<result> results { get; set; }

     
    }

    public class result
    {
        public string currentCity { get; set; }
        public string pm25 { get; set; }

        public IList<indexitem> index { get; set; }
        public IList<weather_data_item> weather_data { get; set; }
    }

    public struct weather_data_item
    {
        public string date { get; set; }
        public string dayPictureUrl { get; set; }
        public string nightPictureUrl { get; set; }
        public string weather { get; set; }
        public string wind { get; set; }
        public string temperature { get; set; }
      


    }

    public struct indexitem
    {

        public string title { get; set; }
        public string zs { get; set; }
        public string tipt { get; set; }
        public string des { get; set; }
    }
}

前台Xmal代码绑定

<Page
    x:Class="Weather.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:Weather"    
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
        <Grid.Background>
            <ImageBrush ImageSource="ms-appx:///Assets/zhuo.jpeg"/>
        </Grid.Background>
        <ProgressRing x:Name="gif"></ProgressRing>
        <Hub  Header="Weather">
            <HubSection>
                <DataTemplate>
                    <StackPanel>
                        <TextBlock Text="{Binding results[0].currentCity}" FontSize="60"></TextBlock>
                        <TextBlock Text="{Binding results[0].pm25}" FontSize="30"></TextBlock>
                    </StackPanel>
                </DataTemplate>
            </HubSection>
            <HubSection>
                <DataTemplate>
                    <ListView ItemsSource="{Binding results[0].weather_data}">
                        <ListView.ItemTemplate>
                            <DataTemplate>

                                <Border Width="360" BorderThickness="2" BorderBrush="Green">
                                    <StackPanel>
                                        <TextBlock Text="{Binding date}" FontSize="25"></TextBlock>
                                        <TextBlock Text="{Binding weather}" FontSize="30"></TextBlock>
                                        <StackPanel Orientation="Horizontal">
                                            <Image Source="{Binding dayPictureUrl}" Stretch="Uniform" Width="60" Height="60"></Image>
                                        </StackPanel>
                                        <TextBlock Text="{Binding wind}" FontSize="25"></TextBlock>
                                        <TextBlock Text="{Binding temperature}" FontSize="30"></TextBlock>

                                    </StackPanel>
                                </Border>

                            </DataTemplate>
                        </ListView.ItemTem
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇[UWP] 使用SemanticZoom控件 下一篇[UWP] 对应用进行A/B测试

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目