{"action":"created","issue":{"url":"https://api.github.com/repos/Windows-XAML/Template10/issues/1218","repository_url":"https://api.github.com/repos/Windows-XAML/Template10","labels_url":"https://api.github.com/repos/Windows-XAML/Template10/issues/1218/labels{/name}","comments_url":"https://api.github.com/repos/Windows-XAML/Template10/issues/1218/comments","events_url":"https://api.github.com/repos/Windows-XAML/Template10/issues/1218/events","html_url":"https://github.com/Windows-XAML/Template10/issues/1218","id":176894974,"number":1218,"title":"Can't show MainView when App has no HamburgerMenu in Shell.xaml","user":{"login":"stalek71","id":6651025,"avatar_url":"https://avatars.githubusercontent.com/u/6651025?v=3","gravatar_id":"","url":"https://api.github.com/users/stalek71","html_url":"https://github.com/stalek71","followers_url":"https://api.github.com/users/stalek71/followers","following_url":"https://api.github.com/users/stalek71/following{/other_user}","gists_url":"https://api.github.com/users/stalek71/gists{/gist_id}","starred_url":"https://api.github.com/users/stalek71/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stalek71/subscriptions","organizations_url":"https://api.github.com/users/stalek71/orgs","repos_url":"https://api.github.com/users/stalek71/repos","events_url":"https://api.github.com/users/stalek71/events{/privacy}","received_events_url":"https://api.github.com/users/stalek71/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-14T12:32:19Z","updated_at":"2016-09-15T12:29:31Z","closed_at":null,"body":"I'd like to create an app that has login page without HamburgerMenu and MainViewPage with hamburger menu. So from my shell I'd like to navigate to login page (without Hamburger) and after login operation to switch to main view. To achieve this goal I removed Hamburger menu definition from Shell.xaml (it's empty now). The following code (below) shows the current state of the code (trying to navigate to MainView from shell). It's fragment of App.cs (App derives from T10.Bootstrapper)\r\n\r\n       public override async Task OnInitializeAsync(IActivatedEventArgs args)\r\n        {\r\n            // Construct dependency container\r\n            CompositionRoot.ConstructContainer();\r\n\r\n            if (Window.Current.Content as ModalDialog == null)\r\n            {\r\n                // Create a new frame \r\n                var navService = NavigationServiceFactory(BackButton.Attach, ExistingContent.Include);\r\n\r\n                // Register navigation instance for injection (in DI container)\r\n                CompositionRoot.Container.RegisterInstance<INavigationService>(navService);\r\n\r\n                // Create modal root\r\n                Window.Current.Content = new ModalDialog\r\n                {\r\n                    DisableBackButtonWhenModal = true,\r\n                    Content = new Shell(navService),\r\n                    ModalContent = new Busy(),\r\n                };\r\n            }\r\n            await Task.CompletedTask;\r\n        }\r\n\r\n        public override INavigable ResolveForPage(Page page, NavigationService navigationService)\r\n        {\r\n            Type pvmTypeFromAttribute = page.GetType().GetTypeInfo().GetCustomAttribute<ViewModelTypeAttribute>()?.ViewModelType;\r\n            if (pvmTypeFromAttribute != null)\r\n            {\r\n                var pageViewModel = CompositionRoot.Container.GetInstance(pvmTypeFromAttribute);\r\n                return pageViewModel as INavigable;\r\n            }\r\n            else\r\n                return base.ResolveForPage(page, navigationService);\r\n        }\r\n\r\n        public override async Task OnStartAsync(StartKind startKind, IActivatedEventArgs args)\r\n        {\r\n            // long-running startup tasks go here\r\n            //await Task.Delay(5000);\r\n\r\n            NavigationService.Navigate(typeof(MainPage));\r\n            await Task.CompletedTask;\r\n        }\r\n \r\nAfter navService creation in OnInitializeAsync the collection of nav services (NavigationServices in WindowsWrapper class) has one navigation service. When code hits breakpoint in OnStartAsync method the collection of nav services contains two instances already, because in InitializeFrameAsync (in Bootstraper class) the code constructed additional Frame because CurrentState has States.Splashing value. See below...\r\n\r\n       private async Task InitializeFrameAsync(IActivatedEventArgs e)\r\n        {\r\n            /*\r\n                InitializeFrameAsync creates a default Frame preceeded by the optional \r\n                splash screen, then OnInitialzieAsync, then the new frame (if necessary).\r\n                This is private because there's no reason for the developer to call this.\r\n            */\r\n\r\n            DebugWrite($\"{nameof(IActivatedEventArgs)}:{e.Kind}\");\r\n\r\n            ShowSplashScreen(e);\r\n            await CallOnInitializeAsync(true, e);\r\n            SetupCustomTitleBar();\r\n\r\n            // if there's custom content then there's nothing to do\r\n            if (CurrentState == States.Splashing)\r\n            {\r\n                Window.Current.Content = CreateRootElement(e);\r\n            }\r\n            else if (Window.Current.Content == null)\r\n            {\r\n                Window.Current.Content = CreateRootElement(e);\r\n            }\r\n            else\r\n            {\r\n                // nothing: custom content\r\n            }\r\n        }\r\n\r\nThe issue is probably because of the definition of NavigationService property in Bootstrapper class (it takes \"FirstOrDefault\" nav service). Currently it's defined as below: \r\n\r\n          public INavigationService NavigationService => WindowWrapper.Current().NavigationServices.FirstOrDefault();\r\n\r\nWhat to do with it? \r\nHow to fix the code to show MainView page using current version of T10?\r\nJust to avoid creation of NavService in OnInitializeAsync (postponing shell initialization until OnStartAsync)  :) ?\r\nThe operation shown below succeeded, but app screen remains the same (navigation succeeded on invisible Frame)...\r\n\r\n    NavigationService.Navigate(typeof(Views.MainPage));\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Windows-XAML/Template10/issues/comments/247314537","html_url":"https://github.com/Windows-XAML/Template10/issues/1218#issuecomment-247314537","issue_url":"https://api.github.com/repos/Windows-XAML/Template10/issues/1218","id":247314537,"user":{"login":"mvermef","id":2018777,"avatar_url":"https://avatars.githubusercontent.com/u/2018777?v=3","gravatar_id":"","url":"https://api.github.com/users/mvermef","html_url":"https://github.com/mvermef","followers_url":"https://api.github.com/users/mvermef/followers","following_url":"https://api.github.com/users/mvermef/following{/other_user}","gists_url":"https://api.github.com/users/mvermef/gists{/gist_id}","starred_url":"https://api.github.com/users/mvermef/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mvermef/subscriptions","organizations_url":"https://api.github.com/users/mvermef/orgs","repos_url":"https://api.github.com/users/mvermef/repos","events_url":"https://api.github.com/users/mvermef/events{/privacy}","received_events_url":"https://api.github.com/users/mvermef/received_events","type":"User","site_admin":false},"created_at":"2016-09-15T12:29:31Z","updated_at":"2016-09-15T12:29:31Z","body":"Oh wait you need to use resolveforpage not navigate now.... Since you're using ioc"}}
{"actor":{"display_login":"mvermef"}}