Hi @Toman, Martin ,
Thanks for reaching out.
Based on your description, you want to update a Label on AboutPage.xaml when a button on MainPage.xaml is pressed, and you are using a TabbedPage where both pages are already created by the Shell.
Below is a working example that recreates your scenario. The key point is:
you must reference the existing AboutPage instance created by the Shell, not create a new AboutPage inside MainPage.
AboutPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiTabDemo.AboutPage"
Title="AboutPage">
<StackLayout Padding="30">
<Label x:Name="textBox1"
x:FieldModifier="public"
Text="This is a test app." />
</StackLayout>
</ContentPage>
AppShell.xaml
<TabbedPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:MauiTabDemo"
x:Class="MauiTabDemo.AppShell">
<local:MainPage Title="Main Page" />
<local:AboutPage Title="About Page" />
</TabbedPage>
AppShell.xaml.cs
namespace MauiTabDemo
{
public partial class AppShell : TabbedPage
{
public AboutPage AboutPageInstance { get; private set; }
public AppShell()
{
InitializeComponent();
// Grab the existing AboutPage instance
AboutPageInstance = this.Children.OfType<AboutPage>().FirstOrDefault();
}
}
}
MainPage.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="MauiTabDemo.MainPage">
<VerticalStackLayout Padding="30">
<Button Text="Change About Page Text"
Clicked="OnCounterClicked"/>
</VerticalStackLayout>
</ContentPage>
MainPage.xaml.cs
namespace MauiTabDemo
{
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
}
private void OnCounterClicked(object sender, EventArgs e)
{
// Get the AppShell instance
var shell = Application.Current.MainPage as AppShell;
if (shell?.AboutPageInstance != null)
{
shell.AboutPageInstance.textBox1.Text = "Hello from MainPage!";
}
}
}
}
In this approach:
- Shell creates both
MainPage and AboutPage when the TabbedPage loads.
- You retrieve the already-created
AboutPage instance from AppShell.Children.
- Updating the Label on that instance updates the UI immediately when the user switches to the tab.
Although the above code works, it is not considered best practice in .NET MAUI because:
- MainPage directly reaches into AboutPage’s UI controls (
textBox1). This breaks encapsulation and makes the app harder to maintain.
- If you add more pages or navigation paths, this approach becomes fragile.
The recommended MAUI architecture is MVVM where:
- Pages bind to a shared ViewModel
- Pages do not manipulate each other
- UI updates happen through data binding
So my recommendation for your project is to use a shared ViewModel and update a property instead of touching controls. Both MainPage and AboutPage bind to the same ViewModel instance. This is clean, scalable, and testable.
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.