• <small id='QmKPK'></small><noframes id='QmKPK'>

      <tfoot id='QmKPK'></tfoot>

      <i id='QmKPK'><tr id='QmKPK'><dt id='QmKPK'><q id='QmKPK'><span id='QmKPK'><b id='QmKPK'><form id='QmKPK'><ins id='QmKPK'></ins><ul id='QmKPK'></ul><sub id='QmKPK'></sub></form><legend id='QmKPK'></legend><bdo id='QmKPK'><pre id='QmKPK'><center id='QmKPK'></center></pre></bdo></b><th id='QmKPK'></th></span></q></dt></tr></i><div id='QmKPK'><tfoot id='QmKPK'></tfoot><dl id='QmKPK'><fieldset id='QmKPK'></fieldset></dl></div>

      1. <legend id='QmKPK'><style id='QmKPK'><dir id='QmKPK'><q id='QmKPK'></q></dir></style></legend>

        • <bdo id='QmKPK'></bdo><ul id='QmKPK'></ul>

        为 Windows Phone 8.1 在页面之间传递数据

        时间:2023-08-28
        <i id='jTEVu'><tr id='jTEVu'><dt id='jTEVu'><q id='jTEVu'><span id='jTEVu'><b id='jTEVu'><form id='jTEVu'><ins id='jTEVu'></ins><ul id='jTEVu'></ul><sub id='jTEVu'></sub></form><legend id='jTEVu'></legend><bdo id='jTEVu'><pre id='jTEVu'><center id='jTEVu'></center></pre></bdo></b><th id='jTEVu'></th></span></q></dt></tr></i><div id='jTEVu'><tfoot id='jTEVu'></tfoot><dl id='jTEVu'><fieldset id='jTEVu'></fieldset></dl></div>

        1. <tfoot id='jTEVu'></tfoot>
        2. <legend id='jTEVu'><style id='jTEVu'><dir id='jTEVu'><q id='jTEVu'></q></dir></style></legend>
              <tbody id='jTEVu'></tbody>
                • <bdo id='jTEVu'></bdo><ul id='jTEVu'></ul>

                  <small id='jTEVu'></small><noframes id='jTEVu'>

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

                  问题描述

                  我的问题与在页面之间传递数据有完全相同的问题,但仅适用于 Windows Phone 8.1(相对于 Windows Phone 7).问题来了:

                  I have the exact same question as Passing data from page to page, but only for Windows Phone 8.1 (opposed to Windows Phone 7). Here is the question:

                  我正在寻找有关如何在页面之间传递数据的最佳实践.

                  I'm looking for the best practice on how to pass data from page to page.

                  在页面 A 中,我有一个触发页面 B 的按钮.在页面 B 我有 6 个文本框,允许用户输入信息.当用户完成后,点击一个按钮将他们带回页面 A.

                  In Page A I have a button that fires off Page B. On Page B I have 6 textboxes that allow the user to enter information. When the user is done, the click on a button that brings them back to Page A.

                  我想将该数据传递回页面 A.

                  I want to pass that data back to Page A.

                  我看到了以下建议:

                  构建 XML 文档并保存到独立存储使用 App 类在属性中存储信息像查询字符串一样传递它我正在寻找最佳实践.有没有一种是 Microsoft 推荐的,或者是公认的最佳方法?

                  build XML documents and save to Isolated Storage use the App class to store information in properties pass it like a query string I'm looking for the Best practice. Is there one that Microsoft recommends or one that is generally accepted as the best way?

                  谢谢

                  推荐答案

                  在 WP8.1 运行时 - 对于 Silverlight,WP8.0 中使用的方法 应该仍然有效 - 您有两个选择:

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

                  • 第一种可能也是最简单的方法是使用 使用参数导航 - 如果它是可序列化类型,则不必将其转换为 string:

                  • 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;
                  }
                  

                • 您可以使用一些静态对象在应用程序中传递您的数据

                • 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.

                  以上是关于正常导航(前进).如果你想在上一个页面中填充一些数据,那么你有几个选择:

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

                  • 将处理程序传递给前一个页面,以便您可以从当前页面访问公共变量/属性,
                  • 使用静态变量/属性 - 可能是单例
                  • 再次使用文件/设置

                  请注意,前两种方法也有一个缺点,即应用程序在暂停后可能会崩溃.在这里保存到文件可能会更好,认为需要更多的工作和适当的处理.

                  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 在页面之间传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                • 上一篇:WPF 选项卡键导航 下一篇:Shift+Tab 在 TreeView 控件中不起作用

                  相关文章

                  最新文章

                      <bdo id='msF05'></bdo><ul id='msF05'></ul>
                    <tfoot id='msF05'></tfoot>
                    <i id='msF05'><tr id='msF05'><dt id='msF05'><q id='msF05'><span id='msF05'><b id='msF05'><form id='msF05'><ins id='msF05'></ins><ul id='msF05'></ul><sub id='msF05'></sub></form><legend id='msF05'></legend><bdo id='msF05'><pre id='msF05'><center id='msF05'></center></pre></bdo></b><th id='msF05'></th></span></q></dt></tr></i><div id='msF05'><tfoot id='msF05'></tfoot><dl id='msF05'><fieldset id='msF05'></fieldset></dl></div>
                  1. <legend id='msF05'><style id='msF05'><dir id='msF05'><q id='msF05'></q></dir></style></legend>
                  2. <small id='msF05'></small><noframes id='msF05'>