积极答复者
windows phone应用如何进行页面导航并传递参数?

问题
答案
-
你好。
1. 页面间导航和参数传递:
Windows Phone 8.0 和 Windows Phone Silverlight 8.1:
NavigationService.Navigate( new Uri("/SomePage.xaml?key1=value1&key2=value2", UriKind.Relative));
参数传递通过key和value的方式拼接在导航地址参数中,传递值类型为字符串。
Windows Phone 8.1:
Frame.Navigate(typeof(SecondPage), param);
参数传递通过参数param实现,传递值类型为object。
2. 这个问题我不太明白。hub中的按钮是什么意思?
看过楼主的前一个问题,里面看到了hub控件构成了人脉应用界面。你说的按钮是指的人脉应用底部的AppBar按钮吗?
如果是的话,那么按钮是AppBarButton,通过按钮的Click事件来执行点击动作。具体见:AppBarButton class
希望我的答案能帮助更多的人。
- 已标记为答案 lxylxy123456 2014年8月9日 8:16
-
1. 参数接收
Windows Phone 8.0 和 Windows Phone Silverlight 8.1:
protected override void OnNavigatedTo(NavigationEventArgs e) { string value1 = NavigationContext.QueryString["key1"]; string value2 = NavigationContext.QueryString["key2"]; }
Windows Phone 8.1:
新建一个“基本页(Basic Page)”作为导航目标页
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { object obj = e.NavigationParameter; }
2. 以“设置账户”按钮为例:
如果你有多个这样的按钮,可以作为TextBlock放入ListView中,通过判断ListView的当前选中Item来判断点击动作。
如果是一个按钮的话,直接作为TextBlock,触发Tap事件来执行点击动作。
希望我的答案能帮助更多的人。
- 已建议为答案 Leo (Apple) YangModerator 2014年8月8日 1:13
- 已标记为答案 lxylxy123456 2014年8月9日 8:16
-
如果就一个按钮,就没有必要使用ListView。
如果是多个,ListView使用方法:
How To Use the Windows Phone 8.1 GridView and ListView Controls
Adding ListView and GridView controls (XAML)
希望我的答案能帮助更多的人。
- 已标记为答案 lxylxy123456 2014年8月9日 8:16
-
您好,邵猛老师的回答已经很详细,很有耐心了。我们遇到问题首先应该自己努力思考,查书籍,官方文档,去搜索。最后才应该去求助他人,不要指望别人把完整的代码给出来,只要有了思路我们就可以努力去实现了。(啰嗦了)
<ListView > <ListView.ItemTemplate> <DataTemplate> <StackPanel > <TextBlock Text="{Binding Key}" FontSize="20"/> <TextBlock Text="{Binding Ps}" FontSize="10"/> <TextBlock Text="{Binding Acception}" TextWrapping="Wrap" FontSize="10"/> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView>
请参考:
http://msdn.microsoft.com/zh-CN/library/windows/apps/xaml/hh780618.aspx
示例代码:
http://code.msdn.microsoft.com/windowsapps/ListViewSimple-d5fc27dd/
希望对你有帮助。 微软官方都有示例代码的,可以学习学习官方的代码
www.bcmeng.com
- 已标记为答案 lxylxy123456 2014年8月9日 8:17
全部回复
-
你好。
1. 页面间导航和参数传递:
Windows Phone 8.0 和 Windows Phone Silverlight 8.1:
NavigationService.Navigate( new Uri("/SomePage.xaml?key1=value1&key2=value2", UriKind.Relative));
参数传递通过key和value的方式拼接在导航地址参数中,传递值类型为字符串。
Windows Phone 8.1:
Frame.Navigate(typeof(SecondPage), param);
参数传递通过参数param实现,传递值类型为object。
2. 这个问题我不太明白。hub中的按钮是什么意思?
看过楼主的前一个问题,里面看到了hub控件构成了人脉应用界面。你说的按钮是指的人脉应用底部的AppBar按钮吗?
如果是的话,那么按钮是AppBarButton,通过按钮的Click事件来执行点击动作。具体见:AppBarButton class
希望我的答案能帮助更多的人。
- 已标记为答案 lxylxy123456 2014年8月9日 8:16
-
1. 参数接收
Windows Phone 8.0 和 Windows Phone Silverlight 8.1:
protected override void OnNavigatedTo(NavigationEventArgs e) { string value1 = NavigationContext.QueryString["key1"]; string value2 = NavigationContext.QueryString["key2"]; }
Windows Phone 8.1:
新建一个“基本页(Basic Page)”作为导航目标页
private void NavigationHelper_LoadState(object sender, LoadStateEventArgs e) { object obj = e.NavigationParameter; }
2. 以“设置账户”按钮为例:
如果你有多个这样的按钮,可以作为TextBlock放入ListView中,通过判断ListView的当前选中Item来判断点击动作。
如果是一个按钮的话,直接作为TextBlock,触发Tap事件来执行点击动作。
希望我的答案能帮助更多的人。
- 已建议为答案 Leo (Apple) YangModerator 2014年8月8日 1:13
- 已标记为答案 lxylxy123456 2014年8月9日 8:16
-
如果就一个按钮,就没有必要使用ListView。
如果是多个,ListView使用方法:
How To Use the Windows Phone 8.1 GridView and ListView Controls
Adding ListView and GridView controls (XAML)
希望我的答案能帮助更多的人。
- 已标记为答案 lxylxy123456 2014年8月9日 8:16
-
您好,邵猛老师的回答已经很详细,很有耐心了。我们遇到问题首先应该自己努力思考,查书籍,官方文档,去搜索。最后才应该去求助他人,不要指望别人把完整的代码给出来,只要有了思路我们就可以努力去实现了。(啰嗦了)
<ListView > <ListView.ItemTemplate> <DataTemplate> <StackPanel > <TextBlock Text="{Binding Key}" FontSize="20"/> <TextBlock Text="{Binding Ps}" FontSize="10"/> <TextBlock Text="{Binding Acception}" TextWrapping="Wrap" FontSize="10"/> </StackPanel> </DataTemplate> </ListView.ItemTemplate> </ListView>
请参考:
http://msdn.microsoft.com/zh-CN/library/windows/apps/xaml/hh780618.aspx
示例代码:
http://code.msdn.microsoft.com/windowsapps/ListViewSimple-d5fc27dd/
希望对你有帮助。 微软官方都有示例代码的,可以学习学习官方的代码
www.bcmeng.com
- 已标记为答案 lxylxy123456 2014年8月9日 8:17