如何将主页中的值传递到Windows Phone app 8.1中的第二页 [英] How to pass a value in main page to second page in windows phone app 8.1

查看:45
本文介绍了如何将主页中的值传递到Windows Phone app 8.1中的第二页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Windows手机应用程序项目的新手。

但我遇到了一些小问题,例如:



1.我不能找到引用using system.windows.navigation

2.如何将主页面中的值传递给.xaml到page2.xaml

3.我怎样才能弹出一个消息框?



我非常厌倦了搜索这些项目而我找不到这些东西......

I am new to the windows phone app project.
But i encountered with some small problems like:

1.I cant find the reference "using system.windows.navigation"
2.How can I pass a value in a main page.xaml to page2.xaml
3.How can I pop up a message box?

I terribly fed up with searching these items and am failed to find out these things ...

推荐答案

1)C#是区分大小写的语言,所以如果你要写的话



1) C# is a case-sensitive language, so if you would write

using system.windows.navigation





它不起作用,你必须使用 System.Windows.Navigation [ ^ ]命名空间。只需确保您也引用DLL,双击引用并查看存在的DLL。



2)我想将数据存储在 App 上下文中,以便两个页面都可以解决传递的数据。





It won't work, you have to use System.Windows.Navigation[^] namespace for your project. Just make sure you are referencing the DLL also, Double-click on References and see what DLLs are present.

2) I would like to have the data stored in the App context so that both of the pages can work around with the data that was passed.

public static object Data { get; set; }





然后可以更改为,





Which can then be altered as,

// Before navigating
App.Data = "String data";
rootFrame.Navigate(typeof(Page2));

// After navigation
var data = (string)App.Data; // Get the data





这样,您就可以将数据从一个页面传递到另一个页面,还可以在Application上下文中维护数据。



3)Metro应用程序中不存在MessageBox。您可以将消息预览为对话框。 Metro应用程序中的消息对话框是 MessageDialog [ ^ ]对象。





This way you will be able to pass the data from one page to another, but also maintains the data in the Application context.

3) MessageBox doesn't exist in Metro applications. You get to preview the message as a dialog. A message dialog in Metro application is MessageDialog[^] object.

new MessageDialog("Message to show").ShowAsync();





请注意,这些是异步模型,你必须使用等待


这篇关于如何将主页中的值传递到Windows Phone app 8.1中的第二页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆