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

相关文章
|
8月前
|
Ubuntu API C++
C++标准库、Windows API及Ubuntu API的综合应用
总之,C++标准库、Windows API和Ubuntu API的综合应用是一项挑战性较大的任务,需要开发者具备跨平台编程的深入知识和丰富经验。通过合理的架构设计和有效的工具选择,可以在不同的操作系统平台上高效地开发和部署应用程序。
310 11
|
9月前
|
安全 Linux 网络安全
Nipper 3.9.0 for Windows & Linux - 网络设备漏洞评估
Nipper 3.9.0 for Windows & Linux - 网络设备漏洞评估
241 0
Nipper 3.9.0 for Windows & Linux - 网络设备漏洞评估
|
监控 安全 网络协议
恶意软件无处逃!国内版“Manus”AiPy开发Windows沙箱工具,进程行为+网络传输层级监控! 头像 豪气的
NImplant.exe 是一款后渗透测试工具,可实现远程管理与持久化控制。其优点包括无文件技术、加密通信和插件扩展,但也存在被检测风险及配置复杂等问题。为深入分析其行为,我们基于 aipy 开发了 Windows 沙箱工具,针对桌面上的 NImplant.exe 进行多维度分析,涵盖进程行为、网络连接(如 TCP 请求、目标 IP/域名)、文件控制等,并生成传输层监控报告与沙箱截图。结果显示,aipy 工具响应迅速,报告清晰易读,满足分析需求。
|
12月前
|
网络协议 安全 测试技术
Windows为何在高速网络环境频繁“失速”?
本文深入剖析了企业在高速网络环境中,因Windows系统限制导致传输速率下降的问题,包括接收缓冲区、安全软件及老旧设备等因素,并提供四步定位法及优化方案,助力企业突破传输瓶颈,提升效率。
|
安全 Ubuntu Linux
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
569 0
Nipper 3.8.0 for Windows & Linux - 网络设备漏洞评估
|
XML 安全 网络安全
Nipper 3.7.0 Windows x64 - 网络设备漏洞评估
Nipper 3.7.0 Windows x64 - 网络设备漏洞评估
286 0
Nipper 3.7.0 Windows x64 - 网络设备漏洞评估
|
安全 Windows
【Azure Cloud Service】在Windows系统中抓取网络包 ( 不需要另外安全抓包工具)
通常,在生产环境中,为了保证系统环境的安全和纯粹,是不建议安装其它软件或排查工具(如果可以安装,也是需要走审批流程)。 本文将介绍一种,不用安装Wireshark / tcpdump 等工具,使用Windows系统自带的 netsh trace 命令来获取网络包的步骤
480 32
|
安全 前端开发 Windows
Windows Electron 应用更新的原理是什么?揭秘 NsisUpdater
本文介绍了 Electron 应用在 Windows 中的更新原理,重点分析了 `NsisUpdater` 类的实现。该类利用 NSIS 脚本,通过初始化、检查更新、下载更新、验证签名和安装更新等步骤,确保应用的更新过程安全可靠。核心功能包括差异下载、签名验证和管理员权限处理,确保更新高效且安全。
626 4
Windows Electron 应用更新的原理是什么?揭秘 NsisUpdater
|
JSON 数据处理 Swift
Swift 中的网络编程,主要介绍了 URLSession 和 Alamofire 两大框架的特点、用法及实际应用
本文深入探讨了 Swift 中的网络编程,主要介绍了 URLSession 和 Alamofire 两大框架的特点、用法及实际应用。URLSession 由苹果提供,支持底层网络控制;Alamofire 则是在 URLSession 基础上增加了更简洁的接口和功能扩展。文章通过具体案例对比了两者的使用方法,帮助开发者根据需求选择合适的网络编程工具。
543 3
|
缓存 监控 网络协议
计算机网络的常用的网络通信命令(Windows)
本文介绍了网络技术中常用的命令,如ping用于检测网络连通性,ipconfig查看TCP/IP配置,netstat监控网络状态,arp显示和修改ARP缓存,at安排任务执行,tracert追踪路由,以及nbtstat获取NetBIOS信息。
481 1