Пример #1
0
        private static NavigationService ConstructNavigationService()
        {
            var ngs = new NavigationService();

            //add login & mainpage
            ngs.Configure(PageKeys.Login.ToString(), typeof(LoginPage));
            ngs.Configure(PageKeys.Welcome.ToString(), typeof(WelcomePage));
            ngs.Configure(PageKeys.Navigation.ToString(), typeof(NavigationPage));
            ngs.Configure(PageKeys.Info.ToString(), typeof(InfoPage));

            //add folder pages
            ngs.Configure(PageKeys.AddFolder.ToString(), typeof(AddFolderPage));
            ngs.Configure(PageKeys.EditFolder.ToString(), typeof(EditFolderPage));

            //entry lookup (connects entries with their View & Edit frame)
            var lookup = new Dictionary <ContentType, Tuple <Type, Type> >()
            {
                { ContentType.Webpage, new Tuple <Type, Type>(typeof(ViewWebpage), typeof(EditWebpage)) },
                { ContentType.Note, new Tuple <Type, Type>(typeof(ViewNote), typeof(EditNote)) },
                { ContentType.CreditCard, new Tuple <Type, Type>(typeof(ViewCreditCard), typeof(EditCreditCard)) },
                { ContentType.OnlineAccount, new Tuple <Type, Type>(typeof(ViewOnlineAccount), typeof(EditOnlineAccount)) },
                { ContentType.Book, new Tuple <Type, Type>(typeof(ViewBook), typeof(EditBook)) },
                { ContentType.Person, new Tuple <Type, Type>(typeof(ViewPerson), typeof(EditPerson)) }
            };

            //add pages of entries
            foreach (var ctm in ContentHelper.GetContentTypeModels())
            {
                if (lookup.ContainsKey(ctm.ContentType))
                {
                    var parameter = new NavigationParameter()
                    {
                        Name          = ctm.Name,
                        ViewModelType = ctm.ViewModelType,
                        ViewFrameType = lookup[ctm.ContentType].Item1,
                        EditFrameType = lookup[ctm.ContentType].Item2
                    };
                    ngs.AddEntryNavigation(ctm.AddPageKey, ctm.EditPageKey, ctm.ViewPageKey, parameter);
                }
            }

            return(ngs);
        }