Simple question that I don't seem to be able to find the answer to anywhere...
In a MAUI app, the first page navigated to when the app opens is the first one listed in the navigation.
How do I set it to be another page?
Googled and searched this site.
I have created a new project setting Route="MainPage"
but the default page is still "Page 1"
<TabBar>
<ShellContent ContentTemplate="{DataTemplate local:NewPage1}" Title="Page 1" />
<ShellContent ContentTemplate="{DataTemplate local:NewPage2}" Route="MainPage" Title="Page 2" />
<ShellContent ContentTemplate="{DataTemplate local:NewPage3}" Title="Page 3" />
</TabBar>
In your AppShell.xaml change the MainPage property to any page you want to show first.
<ShellContent
Title="Home”
ContentTemplate="{DataTemplate local:CustomPage}”
Route="MainPage" />
Also can refer https://youtu.be/gzgbplKvci8?si=MiHMHCoRnIAsFXDg
You can change the first tab bar using CurrentItem="{x:Reference dogsItem}"
where dogsItem
is the name of the ShellContent for that page. Link to documentation: https://learn.microsoft.com/dotnet/maui/fundamentals/shell/tabs#tab-selection
For the issue where the tabs are hidden when Shell.CurrentItem
is set (known MAUI bug), TabBar class the same tag so you can set CurrentItem
in your TabBar declaration XAML instead of Shell.