Esempio n. 1
0
        async Task SetTabbedPage(Dictionary <string, object> parameters, TabbedPage tabbedPage)
        {
            bool hasNavigationPage = false;


            var initializers = new List <Task> {
                HandleInitializations(tabbedPage.BindingContext, parameters)
            };

            hasNavigationPage = tabbedPage.Children.Any(x => x is NavigationPage);

            if (!hasNavigationPage)
            {
                var navTabbedPage = PageFactory.GetNavigationPage(tabbedPage);
                Application.Current.MainPage = navTabbedPage;
            }
            else
            {
                Application.Current.MainPage = tabbedPage;
            }

            for (var i = 0; i < tabbedPage.Children.Count; ++i)
            {
                var tab = tabbedPage.Children[i];
                if (tab is NavigationPage navTab)
                {
                    tab = navTab.CurrentPage;
                }
                var tabPageViewModel = PageFactory.CreateViewModel(tab.GetType().Name);

                if (tabPageViewModel != null)
                {
                    tab.BindingContext = tabPageViewModel;
                    initializers.Add(HandleInitializations(tabPageViewModel, parameters));
                }
            }

            await Task.WhenAll(initializers);
        }