Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Accessing a Page's control properties from another page's code

I have a Page called Page1.

I have another Page called Page2 with a TextBox called TextBox1.

I want to manipulate the Text of TextBox1 using Page1's code.

I have made TextBox1 public using the x:FieldModifier="public" code in XAML. I have then tried to use Page2.TextBox1.Text = x, with no success. How do I do this?

I did not provide any more code, but please tell me if this is not sufficient.

like image 319
Seminix Avatar asked Sep 02 '25 06:09

Seminix


1 Answers

Answer is in the comments. This is posted in case anyone else comes across this

Page2 is a class, you need to make a variable for that class. In Page1, when Page2 is initialized, store it in a variable, then you can update Page2's textbox with the variable.

Page2 page2 = new Page2(); 
page2.TextBox1.Text = "my new text";
like image 79
Lucas Avatar answered Sep 04 '25 19:09

Lucas