求教一个
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
namespace navigate
{
public partial class MainPage : PhoneApplicationPage
{
// 构造函数
public MainPage()
{
InitializeComponent();
}
private void NavigatedBTN_Click(object sender, RoutedEventArgs e)
{
this.NavigationService.Navigate(new Uri("/Page1.xaml",UriKind.Relative));
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
if (State.ContainsKey("Text"))
{
textBox1.Text = State["Text"].ToString();
}
base.OnNavigatedTo(e);
}
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
State["Text"] = textBox1.Text.ToString() + "离开页面时保存的数据";
base.OnNavigatedFrom(e);
}
}
}
为什么在wp8sdk下用Os7.1实现不了墓碑机制,错在哪里? --------------------编程问答-------------------- LZ,你想要什么效果?实际又是什么效果呢?
总要说说吧。 --------------------编程问答-------------------- 就是譬如我弄了个textbox在里面写些东西,不小心按了“Start”或者误关之后再打开程序,里面的内容还在 --------------------编程问答--------------------
你这State是什么? --------------------编程问答-------------------- protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
State["Text"] = textBox1.Text.ToString() + "离开页面时保存的数据";
base.OnNavigatedFrom(e);
}
这个函数有执行吗 --------------------编程问答-------------------- protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
State["Text"] = textBox1.Text.ToString() + "离开页面时保存的数据";
base.OnNavigatedFrom(e);
}
这个函数在不同页面有执行,譬如在page2回到page1可以保存
补充:移动开发 , Windows Phone