Windows Phone 7 네트워크 프로그래밍 일기예보 적용

두 번째 페이지의 코드
ForecastPage.xaml
 

  
  
  
  
  1. <phone:PhoneApplicationPage   
  2.     x:Class="WeatherForecast.ForecastPage" 
  3.     xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
  4.     xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
  5.     xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" 
  6.     xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" 
  7.     xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
  8.     xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
  9.     FontFamily="{StaticResource PhoneFontFamilyNormal}" 
  10.     FontSize="{StaticResource PhoneFontSizeNormal}" 
  11.     Foreground="{StaticResource PhoneForegroundBrush}" 
  12.     SupportedOrientations="Portrait" Orientation="Portrait" 
  13.     mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480" 
  14.     shell:SystemTray.IsVisible="True"> 
  15.       
  16.     <Grid x:Name="LayoutRoot" Background="Transparent"> 
  17.         <Grid.RowDefinitions> 
  18.             <RowDefinition Height="Auto"/> 
  19.             <RowDefinition Height="*"/> 
  20.         </Grid.RowDefinitions> 
  21.         <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="24,24,0,12"> 
  22.             <TextBlock x:Name="ApplicationTitle" Text=" " Style="{StaticResource PhoneTextNormalStyle}"/> 
  23.             <TextBlock x:Name="PageTitle" Text="{Binding City}" Margin="-3,-8,0,0" Style="{StaticResource PhoneTextNormalStyle}"/> 
  24.         </StackPanel> 
  25.         <Grid x:Name="ContentGrid" Grid.Row="1" Margin="12,0,12,0"> 
  26.             <ListBox Height="618" HorizontalAlignment="Left" Margin="0,5,0,0" Name="ForecastList"  VerticalAlignment="Top" Width="474" Grid.RowSpan="2" SelectionChanged="ForecastList_SelectionChanged" > 
  27.                 <ListBox.ItemTemplate><!-- --> 
  28.                     <DataTemplate> 
  29.                         <Grid > 
  30.                             <Grid.RowDefinitions> 
  31.                                 <RowDefinition Height="80"/> 
  32.                                 <RowDefinition Height="80"/> 
  33.                                 <RowDefinition /> 
  34.                                 <RowDefinition Height="*" MinHeight="80" /> 
  35.                             </Grid.RowDefinitions> 
  36.                             <Grid.ColumnDefinitions> 
  37.                                 <ColumnDefinition Width="90" /> 
  38.                                 <ColumnDefinition Width="70"/> 
  39.                                 <ColumnDefinition Width="180"/> 
  40.                                 <ColumnDefinition Width="90"/> 
  41.                             </Grid.ColumnDefinitions> 
  42.                             <TextBlock Text="{Binding Day_of_week}" Foreground="LightBlue"  FontSize="40" Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"/> 
  43.                             <Image Source="{Binding Icon}" Grid.Column="0" Grid.Row="0" VerticalAlignment="Bottom" HorizontalAlignment="Right" Grid.ColumnSpan="2" /> 
  44.                             <TextBlock Text=" (K)"  FontSize="30" Foreground="LightBlue" Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2"/> 
  45.                             <TextBlock Text="{Binding Low}" FontSize="30" Foreground="White" Grid.Column="1" Grid.Row="1"  Grid.ColumnSpan="2" VerticalAlignment="Bottom" HorizontalAlignment="Right"/> 
  46.                             <TextBlock Text=" (K)"  FontSize="30" Foreground="LightBlue" Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2"/> 
  47.                             <TextBlock Text="{Binding High}" FontSize="30" Foreground="White" Grid.Column="1" Grid.Row="2"  Grid.ColumnSpan="2" VerticalAlignment="Bottom" HorizontalAlignment="Right"/> 
  48.                             <TextBlock Text="{Binding Condition}" FontSize="25" Foreground="White" Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="4" TextWrapping="Wrap"/> 
  49.  
  50.                         </Grid> 
  51.                     </DataTemplate> 
  52.                 </ListBox.ItemTemplate> 
  53.             </ListBox> 
  54.         </Grid> 
  55.     </Grid> 
  56. </phone:PhoneApplicationPage> 

 

  
  
  
  
  1. using System.Windows.Controls;  
  2. using Microsoft.Phone.Controls;  
  3. using System.Windows.Navigation;  
  4.  
  5. namespace WeatherForecast  
  6. {  
  7.     public partial class ForecastPage : PhoneApplicationPage  
  8.     {  
  9.         Forecast forecast;  
  10.  
  11.         public ForecastPage()  
  12.         {  
  13.             InitializeComponent();  
  14.         }  
  15.  
  16.         /// <summary> 
  17.         ///  ,  
  18.         /// </summary> 
  19.         protected override void OnNavigatedTo(NavigationEventArgs e)  
  20.         {  
  21.             //  City  
  22.             string cityPinyin = this.NavigationContext.QueryString["City"];  
  23.             forecast = new Forecast();  
  24.             //  
  25.             forecast.GetForecast(cityPinyin);  
  26.             //  forecast  
  27.             DataContext = forecast;  
  28.             //  ForecastList forecast.ForecastList  
  29.             ForecastList.ItemsSource = forecast.ForecastList;  
  30.         }  
  31.  
  32.         private void ForecastList_SelectionChanged(object sender, SelectionChangedEventArgs e)  
  33.         {  
  34.             ForecastList.SelectedIndex = -1;  
  35.             ForecastList.SelectedItem = null;  
  36.  
  37.         }  
  38.     }  

좋은 웹페이지 즐겨찾기