从页将数据传递到页面的Windows

从页将数据传递到页面的Windows

本文介绍了从页将数据传递到页面的Windows Phone 8.1的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

我从页面将数据传递到页面确切同样的问题使用的方法仍然应该努力 - 你有几个choces的:

In WP8.1 Runtime - for Silverlight, the methods used in WP8.0 still should work - you have couple of choces:


  • 第一,可能是最简单的方法是使用 - 你不必将它转化成的字符串的,如果它是一个序列化类型:

  • the first and probably the easiest way is to use Navigate with parameter - you don't have to convert it to string if it's a serializable type:

// let's assume that you have a simple class:
public class PassedData
{
   public string Name { get; set; }
   public int Value { get; set; }
}

// then you navigate like this:
Frame.Navigate(typeof(Page1), new PassedData { Name = "my name", Value = 10 });

// and in target Page you retrive the information:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
    PassedData data = e.Parameter as PassedData;
}


  • 您可以使用一些的静态对象的传递数据一起在App

  • you can use some static objects to pass your data along the App

    请注意,您还必须处理应用程序的暂停/恢复 - 所以这将是适合保存数据的应用程序被挂起时,当它重新加载。你应该记住的的OnNavigatedTo 的,当应用程序在恢复不会被调用。

    Note that you will also have to handle app suspending/resuming - so it will be suitable to save your data when the app is being suspended and load when it's resumed. You should remember that OnNavigatedTo is not being called when the app is resuming.

    以上是关于正常航行(前进)。如果您要填写previous页一些数据,那么你有两个选择:

    The above was about normal navigation (forward). If you want to fill some data in previous Page, then you have a couple of options:


    • 传递处理到previous页,这样你就可以从当前的页面访问公共变量/属性,

    • 使用静态变量/属性 - 可能是单身

    • 再次使用文件/设置

    注意,再前两种方法的缺点在于,应用程序可能被暂停之后崩溃。保存到文件可能会在这里好,思想需要一些更多的工作和妥善处理。

    Note that again the first two methods has a disadvantage that the app may crash after being suspended. Saving to files might be better here, thought needs some more work and proper handling.

    这篇关于从页将数据传递到页面的Windows Phone 8.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    1403页,肝出来的..

  • 09-07 01:22