I'm working on my first MAUI app. It consists of two screens, switchable via a tab control.
Now to my issue - I have page MainPage.xaml with MainPage.xaml.cs and also AboutPage.xaml with AboutPage.xaml.cs.
Is there a way how to access an element of AboutPage.xaml from MainPage.xaml.cs?
My goal is, when I press a button on MainPage.xaml, I want to write a text on AboutPage.xaml, so that it's there when user switches to AboutPage via the tab.
In my AboutPage.xaml, I have
<Label
x:Name="textBox1"
x:FieldModifier="public"
Text="This a test app." />
Then, in MainPage.xaml.cs I would like to do something like
private void OnCounterClicked(object? sender, EventArgs e)
{
count++;
changeAboutText();
}
public void changeAboutText()
{
var aboutPage = new AboutPage();
aboutPage.textBox1.Text = "hello";
}
This does not say any errors when building, but it does not change the text to "hello" on the AboutPage.
Any ideas?
Thanks a lot in advance for any hint!
BR, Martin