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.     }  

 



本文转自linzheng 51CTO博客,原文链接:http://blog.51cto.com/linzheng/1085162

相关文章
|
5月前
|
SQL 分布式计算 Serverless
鹰角网络:EMR Serverless Spark 在《明日方舟》游戏业务的应用
鹰角网络为应对游戏业务高频活动带来的数据潮汐、资源弹性及稳定性需求,采用阿里云 EMR Serverless Spark 替代原有架构。迁移后实现研发效率提升,支持业务快速发展、计算效率提升,增强SLA保障,稳定性提升,降低运维成本,并支撑全球化数据架构部署。
499 56
鹰角网络:EMR Serverless Spark 在《明日方舟》游戏业务的应用
|
4月前
|
人工智能 监控 安全
NTP网络子钟的技术架构与行业应用解析
在数字化与智能化时代,时间同步精度至关重要。西安同步电子科技有限公司专注时间频率领域,以“同步天下”品牌提供可靠解决方案。其明星产品SYN6109型NTP网络子钟基于网络时间协议,实现高精度时间同步,广泛应用于考场、医院、智慧场景等领域。公司坚持技术创新,产品通过权威认证,未来将结合5G、物联网等技术推动行业进步,引领精准时间管理新时代。
|
5月前
|
存储 SQL 运维
中国联通网络资源湖仓一体应用实践
本文分享了中国联通技术专家李晓昱在Flink Forward Asia 2024上的演讲,介绍如何借助Flink+Paimon湖仓一体架构解决传统数仓处理百亿级数据的瓶颈。内容涵盖网络资源中心概况、现有挑战、新架构设计及实施效果。新方案实现了数据一致性100%,同步延迟从3小时降至3分钟,存储成本降低50%,为通信行业提供了高效的数据管理范例。未来将深化流式数仓与智能运维融合,推动数字化升级。
213 0
中国联通网络资源湖仓一体应用实践
|
7月前
|
机器学习/深度学习 编解码 自动驾驶
RT-DETR改进策略【模型轻量化】| 替换骨干网络为MoblieNetV1,用于移动视觉应用的高效卷积神经网络
RT-DETR改进策略【模型轻量化】| 替换骨干网络为MoblieNetV1,用于移动视觉应用的高效卷积神经网络
226 3
RT-DETR改进策略【模型轻量化】| 替换骨干网络为MoblieNetV1,用于移动视觉应用的高效卷积神经网络
|
4月前
|
机器学习/深度学习 算法 测试技术
图神经网络在信息检索重排序中的应用:原理、架构与Python代码解析
本文探讨了基于图的重排序方法在信息检索领域的应用与前景。传统两阶段检索架构中,初始检索速度快但结果可能含噪声,重排序阶段通过强大语言模型提升精度,但仍面临复杂需求挑战
125 0
图神经网络在信息检索重排序中的应用:原理、架构与Python代码解析
|
3月前
|
监控 安全 Linux
AWK在网络安全中的高效应用:从日志分析到威胁狩猎
本文深入探讨AWK在网络安全中的高效应用,涵盖日志分析、威胁狩猎及应急响应等场景。通过实战技巧,助力安全工程师将日志分析效率提升3倍以上,构建轻量级监控方案。文章详解AWK核心语法与网络安全专用技巧,如时间范围分析、多条件过滤和数据脱敏,并提供性能优化与工具集成方案。掌握AWK,让安全工作事半功倍!
85 0
|
3月前
|
人工智能 安全 网络安全
网络安全厂商F5推出AI Gateway,化解大模型应用风险
网络安全厂商F5推出AI Gateway,化解大模型应用风险
122 0
|
4月前
|
安全 Ubuntu Linux
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
144 0
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
|
5月前
|
XML 安全 网络安全
Nipper 3.7.0 Windows x64 - 网络设备漏洞评估
Nipper 3.7.0 Windows x64 - 网络设备漏洞评估
111 0
Nipper 3.7.0 Windows x64 - 网络设备漏洞评估
|
6月前
|
Java 数据库连接 API
YashanDB应用程序与网络体系
YashanDB应用程序与网络体系

热门文章

最新文章