<Page
    x:Class="WeatherService.MainPage"
    IsTabStop="false"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WeatherService"
    xmlns:common="using:WeatherService.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d">

    <Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <TextBlock Text="Prognoza pogody" 
                   Margin="12"
                   Style="{StaticResource HeaderTextStyle}"/>
        <StackPanel Orientation="Horizontal" Grid.Row="1" Margin="12">
            <TextBlock Text="Podaj kod pocztowy:" Style="{StaticResource SubheaderTextStyle}"/>
            <TextBox x:Name="ZipCode" Margin="5 0 0 0" Width="100"/>
            <Button Content="Start" Margin="5 0 0 0" Click="Button_Click_1"/>
        </StackPanel>        
        <Grid Grid.Row="2" Margin="12" x:Name="ResultsGrid">
            <Grid.Resources>
                <common:DateConverter x:Key="ConvertDate"/>
                <common:ImageConverter x:Key="ConvertImage"/>
            </Grid.Resources>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>                
            </Grid.RowDefinitions>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding City}"/>
                <TextBlock Text=","/>
                <TextBlock Text="{Binding State}"/>
            </StackPanel>
            <ListView Grid.Row="1" ItemsSource="{Binding ForecastResult}">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="{Binding Date, Converter={StaticResource ConvertDate}}"
                                        Width="200"/>
                            <TextBlock Text="{Binding Desciption}" Width="150" Margin="5 0 0 0"/>
                            <Image Source="{Binding Desciption, Converter={StaticResource ConvertImage}}"/>
                            <TextBlock Text="{Binding Temperatures.MorningLow}" Margin="5 0 0 0" Width="50"/>
                            <TextBlock Text="{Binding Temperatures.DaytimeHigh}" Margin="5 0 0 0" Width="50"/>
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Grid>
        
    </Grid>
</Page>
