• windows phone不同页面间传值


    在windows phone中,不同页面间传值是用以下代码就可以了

    PhoneApplicationService.Current.State[“strKey”]

    我自己封装的代码:

    TripDealer.cs:

    using System;
    using System.Net;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Documents;
    using System.Windows.Ink;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Animation;
    using System.Windows.Shapes;
    using Microsoft.Phone.Shell;

    namespace lifeCircle.Classes
    {
        public class TripDealer
        {
            private const string tripKey = "trip";

            public TripInfo CurrentTrip
            {
                get
                {
                    if (!PhoneApplicationService.Current.State.ContainsKey(tripKey))
                    {
                        return null;
                    }
                    else
                    {
                        return PhoneApplicationService.Current.State[tripKey] as TripInfo;
                    }
                }
                set { PhoneApplicationService.Current.State[tripKey] = value; }
            }
           
        }
    }

    consuming Code:

    using lifeCircle.Classes;

    TripDealer objDealer = new TripDealer();

    if (null == objDealer.CurrentTrip)
                {
                    tbDate.Text = DateTime.Now.ToString("yyyy-MM-dd");
                }

    if (null == objDealer.CurrentTrip)
                {
                    objDealer.CurrentTrip = new TripInfo();
                }
                objDealer.CurrentTrip.Name = tbTripName.Text;
                objDealer.CurrentTrip.TripDate = DateTime.Parse(tbDate.Text);
                objDealer.CurrentTrip.MemberList = tbMembers.Text;
                NavigationService.Navigate(new Uri("/Pages/TripEditSecond.xaml",UriKind.Relative));

  • 相关阅读:
    ES6新语法之---块作用域let/const(2)
    sass变量
    Ruby(或cmd中)输入命令行编译sass
    sass的安装
    鼠标滚动兼容
    HTML5新标签兼容——> <!--<if lt IE 9><!endif-->
    #include stdio.h(7)
    #include stdio.h(6)
    #include stdio.h(5)
    #include stdio.h(3)
  • 原文地址:https://www.cnblogs.com/binaryworms/p/2618200.html
Copyright © 2020-2023  润新知