{"action":"created","issue":{"url":"https://api.github.com/repos/Windows-XAML/Template10/issues/921","repository_url":"https://api.github.com/repos/Windows-XAML/Template10","labels_url":"https://api.github.com/repos/Windows-XAML/Template10/issues/921/labels{/name}","comments_url":"https://api.github.com/repos/Windows-XAML/Template10/issues/921/comments","events_url":"https://api.github.com/repos/Windows-XAML/Template10/issues/921/events","html_url":"https://github.com/Windows-XAML/Template10/issues/921","id":153560322,"number":921,"title":"NavigationService DI resolver creates new viewmodel instances on all nav events","user":{"login":"dpakpaul","id":3280816,"avatar_url":"https://avatars.githubusercontent.com/u/3280816?v=3","gravatar_id":"","url":"https://api.github.com/users/dpakpaul","html_url":"https://github.com/dpakpaul","followers_url":"https://api.github.com/users/dpakpaul/followers","following_url":"https://api.github.com/users/dpakpaul/following{/other_user}","gists_url":"https://api.github.com/users/dpakpaul/gists{/gist_id}","starred_url":"https://api.github.com/users/dpakpaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpakpaul/subscriptions","organizations_url":"https://api.github.com/users/dpakpaul/orgs","repos_url":"https://api.github.com/users/dpakpaul/repos","events_url":"https://api.github.com/users/dpakpaul/events{/privacy}","received_events_url":"https://api.github.com/users/dpakpaul/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/Windows-XAML/Template10/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/Windows-XAML/Template10/labels/help%20wanted","name":"help wanted","color":"159818"}],"state":"open","locked":false,"assignee":{"login":"JerryNixon","id":1749983,"avatar_url":"https://avatars.githubusercontent.com/u/1749983?v=3","gravatar_id":"","url":"https://api.github.com/users/JerryNixon","html_url":"https://github.com/JerryNixon","followers_url":"https://api.github.com/users/JerryNixon/followers","following_url":"https://api.github.com/users/JerryNixon/following{/other_user}","gists_url":"https://api.github.com/users/JerryNixon/gists{/gist_id}","starred_url":"https://api.github.com/users/JerryNixon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JerryNixon/subscriptions","organizations_url":"https://api.github.com/users/JerryNixon/orgs","repos_url":"https://api.github.com/users/JerryNixon/repos","events_url":"https://api.github.com/users/JerryNixon/events{/privacy}","received_events_url":"https://api.github.com/users/JerryNixon/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/Windows-XAML/Template10/milestones/6","html_url":"https://github.com/Windows-XAML/Template10/milestones/Nuget%20Library%20v1.1.11","labels_url":"https://api.github.com/repos/Windows-XAML/Template10/milestones/6/labels","id":1723756,"number":6,"title":"Nuget Library v1.1.11","description":"","creator":{"login":"JerryNixon","id":1749983,"avatar_url":"https://avatars.githubusercontent.com/u/1749983?v=3","gravatar_id":"","url":"https://api.github.com/users/JerryNixon","html_url":"https://github.com/JerryNixon","followers_url":"https://api.github.com/users/JerryNixon/followers","following_url":"https://api.github.com/users/JerryNixon/following{/other_user}","gists_url":"https://api.github.com/users/JerryNixon/gists{/gist_id}","starred_url":"https://api.github.com/users/JerryNixon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JerryNixon/subscriptions","organizations_url":"https://api.github.com/users/JerryNixon/orgs","repos_url":"https://api.github.com/users/JerryNixon/repos","events_url":"https://api.github.com/users/JerryNixon/events{/privacy}","received_events_url":"https://api.github.com/users/JerryNixon/received_events","type":"User","site_admin":false},"open_issues":5,"closed_issues":22,"state":"open","created_at":"2016-04-21T20:07:51Z","updated_at":"2016-05-07T01:20:50Z","due_on":null,"closed_at":null},"comments":2,"created_at":"2016-05-07T00:02:40Z","updated_at":"2016-05-07T01:43:07Z","closed_at":null,"body":"In the NavigationService, the Navigate* and Navigating* methods call ResolveForPage(). The code for that method I think is missing the following line after calling BootStrapper.Current.ResolveForPage() \r\n\r\n`page.DataContext = viewModel;`\r\n\r\nSince the page DataContext isn't set, all the navigation \"events\" on a given page will create a new viewmodel instance from the overridden Bootstrapper ResolveForPage() if you're using that to DI your viewmodel.\r\n\r\nI know one can set the page.DataContext in the Bootstrapper ResolveForPage() override to workaround this, but the NavigationService is probably the right place for this. \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/Windows-XAML/Template10/issues/comments/217597560","html_url":"https://github.com/Windows-XAML/Template10/issues/921#issuecomment-217597560","issue_url":"https://api.github.com/repos/Windows-XAML/Template10/issues/921","id":217597560,"user":{"login":"dpakpaul","id":3280816,"avatar_url":"https://avatars.githubusercontent.com/u/3280816?v=3","gravatar_id":"","url":"https://api.github.com/users/dpakpaul","html_url":"https://github.com/dpakpaul","followers_url":"https://api.github.com/users/dpakpaul/followers","following_url":"https://api.github.com/users/dpakpaul/following{/other_user}","gists_url":"https://api.github.com/users/dpakpaul/gists{/gist_id}","starred_url":"https://api.github.com/users/dpakpaul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpakpaul/subscriptions","organizations_url":"https://api.github.com/users/dpakpaul/orgs","repos_url":"https://api.github.com/users/dpakpaul/repos","events_url":"https://api.github.com/users/dpakpaul/events{/privacy}","received_events_url":"https://api.github.com/users/dpakpaul/received_events","type":"User","site_admin":false},"created_at":"2016-05-07T01:43:07Z","updated_at":"2016-05-07T01:43:07Z","body":"I can. I'll get to it Monday PST although if there are weekend warriors who\nwant to do the one line fix, they're welcome to .\n\nOn Friday, May 6, 2016, Jerry Nixon <notifications@github.com> wrote:\n\n> You are right. Do you want to submit a Pull Request?\n>\n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly or view it on GitHub\n> <https://github.com/Windows-XAML/Template10/issues/921#issuecomment-217594987>\n>\n"}}