打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
Windows8页面参数传递

Windows8页面参数传递

(2013-01-17 10:14:48)
标签:

杂谈

  1. public class Product  
  2.  
  3.     public string ProductName getset 
  4.   
  5.     public string ProductID getset 
  6. }  
  7. <</span>Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">  
  8.     <</span>StackPanel Margin="30">  
  9.         <</span>TextBlock Text="通过页面传递的参数:" Style="{StaticResource HeaderTextStyle}"/>  
  10.           
  11.         <</span>StackPanel Orientation="Horizontal" Margin="5,80,0,10">  
  12.             <</span>TextBlock Text="产品编号:" FontSize="28"/>  
  13.             <</span>TextBlock Name="tbProID" FontSize="28"/>  
  14.         </</span>StackPanel>  
  15.           
  16.         <</span>StackPanel Orientation="Horizontal" Margin="5,13,0,0">  
  17.             <</span>TextBlock Text="产品名称:" FontSize="28"/>  
  18.             <</span>TextBlock Name="tbProName" FontSize="28"/>  
  19.         </</span>StackPanel>  
  20.     </</span>StackPanel>  
  21. </</span>Grid>  
  22. protected override void OnNavigatedTo(NavigationEventArgs e)  
  23.  
  24.     // 获取参数  
  25.     Product product e.Parameter as Product;  
  26.     if (product != null 
  27.      
  28.         this.tbProID.Text product.ProductID;  
  29.         this.tbProName.Text product.ProductName;  
  30.      
  31. }  
  32. <</span>Grid Background="{StaticResource ApplicationPageBackgroundThemeBrush}">  
  33.     <</span>StackPanel Margin="30">  
  34.         <</span>TextBlock Text="输入产品编号:" Style="{StaticResource SubheaderTextStyle}"/>  
  35.         <</span>TextBox Name="txtID" Margin="5,10,5,0"/>  
  36.         <</span>TextBlock Margin="0,20,0,0" Text="输入产品名称:" Style="{StaticResource SubheaderTextStyle}"/>  
  37.         <</span>TextBox Name="txtName" Margin="5,10,5,0"/>  
  38.         <</span>Button Content="跳转" Padding="35,10,35,10" Margin="15,20,0,0" Click="onNav"/>  
  39.     </</span>StackPanel>  
  40. </</span>Grid> 
  41. private void onNav(object sender, RoutedEventArgs e)  
  42.  
  43.     // 取出当前窗口的根Frame  
  44.     if (Window.Current.Content is Frame && Window.Current.Content != null 
  45.      
  46.         Frame myFrame Window.Current.Content as Frame;  
  47.         Product prd new Product()  
  48.          
  49.             ProductID txtID.Text,  
  50.             ProductName txtName.Text  
  51.         };  
  52.         // 导航到目标页面并传递参数  
  53.         myFrame.Navigate(typeof(PageGet), prd);  
  54.      



本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Material Design Object
Windows Phone新手开发教程(二)
一步一步学Silverlight 2系列(3):界面布局
RadioButton
WPF
Silverlight 4常用StringFormat格式总结
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服