I created a new blank page xaml for windows 8 app. I have a textbox in the main page so the users can type their name in the main page. Also it has a button so that they can open new frame which is the blank page with the following codes :
this.Frame.Navigate(typeof(BlankPage1));
I made a get set class for the textbox so that they can see the value of the textbox in the blank page.
public string t1
{
get { return textbox1.Text; }
set { textbox1.Text = value; }
}
And these are the codes for the blank page :
protected override void OnNavigatedTo(NavigationEventArgs e)
{
MainPage p1 = new MainPage();
textbox1.Text = p1.t1;
}
But it won't show the value of the textbox in the blank page. It only shows "TextBox" in the textbox
The problem is that you're creating a new MainPage
in the OnNavigatedTo
- but you're not actually showing it.
You need to have a reference to the existing instance of MainPage
- the one that's visible - not just some arbitrary new instance.
(As an aside, your t1
member is a property - there's no such thing as a "get set class".)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.