C# 如何将文本框文本从空白页转到主页?
我想从blankpage.xaml获取到Mainpage.xaml的文本 我尝试在MainPage.xaml上使用此选项:C# 如何将文本框文本从空白页转到主页?,c#,xaml,windows-store-apps,C#,Xaml,Windows Store Apps,我想从blankpage.xaml获取到Mainpage.xaml的文本 我尝试在MainPage.xaml上使用此选项: protected override void OnNavigatedTo(NavigationEventArgs e) { enter.Text = (App.Current as App).trytext; } 但trytext找不到一个错误,因此我使用and if语句: protected override void OnNavigatedTo(Navigati
protected override void OnNavigatedTo(NavigationEventArgs e)
{
enter.Text = (App.Current as App).trytext;
}
但trytext找不到一个错误,因此我使用and if语句:
protected override void OnNavigatedTo(NavigationEventArgs e)
{
if (enter.Text == "")
{
enter.Text = "";
}
else
{
enter.Text = (App.Current as App).trytext;
}
}
但是当我从blankpage获取文本时,当我返回到mainpage时就没有文本了
请帮忙 我不确定您想做什么,但似乎您想创建一个可以通过整个应用程序访问的变量 如果要将某些数据从第1页传递到第2页,可以在Navigate方法中传递信息 也许你是在打类似的电话
Frame.Navigate(typeof(MainPage));
导航方法有一个额外的参数,您可以在其中传递信息。像Frame.Navigate(typeof(MainPage),enter.Text)那样调用它代码>
在OnNavigatedTo中,可以从NavigationEventArgs获取值。
可能是这样的:
enter.Text = e.Parameter.ToString();