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

  • 相关阅读:
    leetcode[164] Maximum Gap
    leetcode[162] Find Peak Element
    leetcode[160] Intersection of Two Linked Lists
    leetcode[156] binary tree upside down
    leetcode[155] Min Stack
    leetcode Find Minimum in Rotated Sorted Array II
    leetcode Find Minimum in Rotated Sorted Array
    leetcode Maximum Product Subarray
    ROP
    windbg bp condition
  • 原文地址:https://www.cnblogs.com/binaryworms/p/2618200.html
Copyright © 2020-2023  润新知