I'm trying to change my MainPage, according to which page are marked in my RadioButton Group, in my settings. So if is marked the first will be "APage", else, "BPage".
But when I try to change MainPage = new AppShell();
it just ignore and don't go to another page.
My standard MainPage is registered as:
<ShellContent Title="{x:Static resource:AppResources.home}" Icon="home_icon.png" Route="MainPage" ContentTemplate="{DataTemplate local:MainPage}" />
, but I tried to remove this Route
and do something like this:
DatabaseAccess DAO = new DatabaseAccess();
if (Convert.ToInt32(DAO.GetRadioValue()[0].RadioButtonValue) == 1)
category.Route = "MainPage";
else
home.Route = "MainPage";
but it still doesn't work.
Even if I go to the code-behind of my standard MainPage and put Shell.Current.GoToAsync(nameof(CategoryPage));
do nothing.
Any ideas?
You can use
<ShellContent ... Route="xxx" />
on the xaml page or useRouting.RegisterRoute("xxx", typeof(xxx));
on the cs page to register Route.Then check your
DAO.GetRadioValue()[0].RadioButtonValue
value and useawait Shell.Current.GoToAsync("xxx");
for page jump.You can check this link (https://learn.microsoft.com/en-us/xamarin/xamarin-forms/app-fundamentals/shell/navigation) for more information.