Exemplo n.º 1
0
        public FreshShellPage(Page page, string navigationPageName)

        {
            var pageModel = page.GetModel();

            if (pageModel == null)
            {
                throw new InvalidCastException("BindingContext was not a FreshBasePageModel on this Page");
            }

            pageModel.CurrentNavigationServiceName = navigationPageName;
            NavigationServiceName = navigationPageName;
            RegisterNavigation();

            var shellPage = page as Shell;

            if (shellPage != null)
            {
                //this._shellItem.Add(shellPage);
                foreach (ShellItem shellItem in shellPage.Items)
                {
                    var c = shellItem.Items;
                    foreach (ShellSection cc in c)
                    {
                        ShellContentCollection scc = cc.Items;
                        foreach (ShellContent sitem in scc)
                        {
                            var shellContentPage = sitem.Content as Page;
                            if (shellContentPage == null)
                            {
                                break;
                            }

                            //var vm = shellContentPage.GetModel();
                            //if (vm == null)
                            //break;

                            var name     = GetTypeByPageName(shellContentPage.GetType());
                            var pageType = Type.GetType(name);
                            if (pageType == null)
                            {
                                throw new Exception(name + " not found");
                            }
                            var vm = (FreshBasePageModel)FreshIOC.Container.Resolve(pageType);



                            var bindedPage = FreshPageModelResolver.ResolvePageModel(vm.GetType(), null);
                            sitem.Content = bindedPage;
                            //sitem.BindingContext = vm;
                        }
                    }

                    //AddShell
                    this.Items.Add(shellItem);
                }
            }
        }
Exemplo n.º 2
0
 public static ShellSection Items(this ShellSection shell, ShellContentCollection collection)
 {
     collection.ForEach(section => shell.Items.Add(section));
     return(shell);
 }