Hi there
I'm using the Prism. I have 4 tabs in my Tabbed Page: Home (static no OnNavigatedTo required, Activity (OnNavigatedTo required), Note (OnNavigatedTo required) and more page (OnNavigatedTo not required).
How do I trigger this OnNavigatedTo for this second and third tab? I tested this without the tab ie. using NavigationPage/ActivityList and the OnNavigatedTo working OK.
Found this code for code-behind for tabbed page BUT not sure what it does.
CustomTabbedPage.xaml:
<TabbedPage.Children> <NavigationPage Title="Home" IconImageSource="home.png"> <x:Arguments> <local:HomePage/> </x:Arguments> </NavigationPage> <NavigationPage Title="Activity" IconImageSource="activity.png"> <x:Arguments> <local:ActivityListPage/> </x:Arguments> </NavigationPage> <NavigationPage Title="Note" IconImageSource="note.png"> <x:Arguments> <local:ActivityListPage/> </x:Arguments> </NavigationPage> <NavigationPage Title="More" IconImageSource="more.png"> <x:Arguments> <local:MorePage/> </x:Arguments> </NavigationPage> </TabbedPage.Children>
CustomTabbedPage.xaml.cs :
public void OnNavigatedTo(INavigationParameters parameters)
{
if (parameters.GetNavigationMode() == NavigationMode.New)
{
if (Children.Count == 1)
{
return;
}
for (var pageIndex = 1; pageIndex < Children.Count; pageIndex++)
{
var page = Children[pageIndex];
(page?.BindingContext as INavigationAware)?.OnNavigatedTo(parameters);
}
}
}
app.xaml.cs
protected override async void OnInitialized()
{
InitializeComponent();
if (!string.IsNullOrEmpty(Preferences.Get(Constant.Setting_AccessToken, "")))
{
var result = await NavigationService.NavigateAsync("CustomTabbedPage?selectedTab=HomePage");
}
else if (string.IsNullOrEmpty(Preferences.Get(Constant.Setting_UserEmail, "")) &&
string.IsNullOrEmpty(Preferences.Get(Constant.Setting_Password, "")))
{
var result = await NavigationService.NavigateAsync("/LoginPage");
}
}