{"action":"created","issue":{"url":"https://api.github.com/repos/PrismLibrary/Prism/issues/358","labels_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/358/labels{/name}","comments_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/358/comments","events_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/358/events","html_url":"https://github.com/PrismLibrary/Prism/issues/358","id":122334736,"number":358,"title":"[XF] new 6.2 OnInitialized running prior to App main constructor, causing page navigation prior to initializing an app.xaml.cs","user":{"login":"JeffDalby","id":15741016,"avatar_url":"https://avatars.githubusercontent.com/u/15741016?v=3","gravatar_id":"","url":"https://api.github.com/users/JeffDalby","html_url":"https://github.com/JeffDalby","followers_url":"https://api.github.com/users/JeffDalby/followers","following_url":"https://api.github.com/users/JeffDalby/following{/other_user}","gists_url":"https://api.github.com/users/JeffDalby/gists{/gist_id}","starred_url":"https://api.github.com/users/JeffDalby/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeffDalby/subscriptions","organizations_url":"https://api.github.com/users/JeffDalby/orgs","repos_url":"https://api.github.com/users/JeffDalby/repos","events_url":"https://api.github.com/users/JeffDalby/events{/privacy}","received_events_url":"https://api.github.com/users/JeffDalby/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-12-15T18:27:05Z","updated_at":"2015-12-15T20:44:38Z","closed_at":null,"body":"\r\nAs I'm implementing this it looks like we don't need to run the bs.run() like in the old.  Seems you've got it to run it's Initialize routine without having to call it somehow...I've not looked into the new code yet so I've not looked at how you pulled that off.   But what I am seeing is that it's firing the OnInitialized routine prior to the App main constructor in an app.xaml.cs file.  \r\n\r\nIn our app I've switched it to using an app.xaml.cs and and app.xaml file so I can have an app wide resource dictionary for styles and such.   What I'm seeing happening is that the InitializeComponent() in the app constructor fires off after the bootstrapper's OnInitialize runs which navigates to a page that requires a style in the app.xaml.  End result being it can't find the style since it navigated to the page prior to the the apps InitializeComponent running and it tanks.\r\n\r\nNow I can totally hacky get around that by doing this:\r\n\r\n    public class Bootstrapper : PrismApplication\r\n    {\r\n        private int timesrun = 0;\r\n        protected async override void OnInitialized()\r\n        {\r\n           if (timesrun != 0)\r\n             {do work}\r\n           timesrun++}\r\n}\r\n\r\nand then call bs.Initialize(); after InitializeComponent(); in the app.xaml.cs file to run it a second time. So that seems to verify things are running out of order, but it's not the prettiest solution ever. :-)\r\n\r\nI'll copy this to the issues page as well.  But figured I'd post here in case someone wants to play around with the latest stuff and needs a temporary hack to get around the problem."},"comment":{"url":"https://api.github.com/repos/PrismLibrary/Prism/issues/comments/164891004","html_url":"https://github.com/PrismLibrary/Prism/issues/358#issuecomment-164891004","issue_url":"https://api.github.com/repos/PrismLibrary/Prism/issues/358","id":164891004,"user":{"login":"brianlagunas","id":835562,"avatar_url":"https://avatars.githubusercontent.com/u/835562?v=3","gravatar_id":"","url":"https://api.github.com/users/brianlagunas","html_url":"https://github.com/brianlagunas","followers_url":"https://api.github.com/users/brianlagunas/followers","following_url":"https://api.github.com/users/brianlagunas/following{/other_user}","gists_url":"https://api.github.com/users/brianlagunas/gists{/gist_id}","starred_url":"https://api.github.com/users/brianlagunas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brianlagunas/subscriptions","organizations_url":"https://api.github.com/users/brianlagunas/orgs","repos_url":"https://api.github.com/users/brianlagunas/repos","events_url":"https://api.github.com/users/brianlagunas/events{/privacy}","received_events_url":"https://api.github.com/users/brianlagunas/received_events","type":"User","site_admin":false},"created_at":"2015-12-15T20:44:38Z","updated_at":"2015-12-15T20:44:38Z","body":"Interesting.  I haven't had a chance to test that scenario yet.  So it seems that if you are using the App.xaml approach, the InitializeComponent has to fire before the base ctor of the PrismApplication.  Since the initialization of the PrismApplication happens in the constructor before the InitializeComponent, try moving the call to InitializeComponent to the Oninitialized method before you navigate.  I'm not at my computer, so I haven't tested that, but it seems like they should work.  Let me know if that works, and I'll add it to the docs."}}