简体   繁体   English

数据传递Windows Phone 8.1

[英]Data passing windows phone 8.1

I am creating a windows phone 8.1 app that has 2 forms: the mainPage and the secondePage . 我正在创建具有2种形式的Windows Phone 8.1应用程序: mainPagesecondePage

The mainPage is the page that loads first, and I have a button to go to secondePage , then I must pass some data from secondePage to mainPage and that's when I got a NullReferenceException because the data I "passed" didn't actually pass. mainPage是首先加载的页面,我有一个按钮转到secondePage ,然后我必须将一些数据从secondePagemainPage ,那是我收到NullReferenceException的原因,因为我“传递”的数据实际上没有传递。

I tried some code I found here on stackoverflow and in some tutorials but it didn't work because they use an expression in the OnNavigatedTo function and I'm passing data from second to mainPage . 我尝试了一些在stackoverflow和一些教程中找到的代码,但由于它们在OnNavigatedTo函数中使用了表达式,并且将数据从第二个传递到mainPage ,因此无法正常工作。 Can you help me find a way to get this data passed? 您能帮我找到一种方法来传递这些数据吗?

You could possibly try using Isolated Storage? 您可以尝试使用隔离存储吗? for example you could save the data eg - text from a textbox and have at load up when you open the second page? 例如,您可以保存数据,例如-来自文本框的文本,并且在打开第二页时处于加载状态? just some food for thought 只是一些思考

Need to see your code, but to save you time, view this link: 需要查看您的代码,但为了节省时间,请查看以下链接:

You may find the answer at that link as it answers these questions: 您可以在该链接上回答以下问题,找到答案:

  1. When navigating between pages in an XAML application how do you pass parameters? 在XAML应用程序中的页面之间导航时,如何传递参数?
  2. What is the difference between using the Uri navigation and manual navigation? 使用Uri导航和手动导航有什么区别?
  3. How can objects (not just strings) be passed when using Uri navigation? 使用Uri导航时如何传递对象(不仅仅是字符串)?

If this answered your question, please mark this as answered. 如果这回答了您的问题,请将其标记为已回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM