{"action":"created","issue":{"url":"https://api.github.com/repos/jsthibault/Domo-Think-EIP/issues/1","repository_url":"https://api.github.com/repos/jsthibault/Domo-Think-EIP","labels_url":"https://api.github.com/repos/jsthibault/Domo-Think-EIP/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/jsthibault/Domo-Think-EIP/issues/1/comments","events_url":"https://api.github.com/repos/jsthibault/Domo-Think-EIP/issues/1/events","html_url":"https://github.com/jsthibault/Domo-Think-EIP/issues/1","id":175486764,"number":1,"title":"Separate ViewModel and View logic","user":{"login":"Eastrall","id":4021025,"avatar_url":"https://avatars.githubusercontent.com/u/4021025?v=3","gravatar_id":"","url":"https://api.github.com/users/Eastrall","html_url":"https://github.com/Eastrall","followers_url":"https://api.github.com/users/Eastrall/followers","following_url":"https://api.github.com/users/Eastrall/following{/other_user}","gists_url":"https://api.github.com/users/Eastrall/gists{/gist_id}","starred_url":"https://api.github.com/users/Eastrall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eastrall/subscriptions","organizations_url":"https://api.github.com/users/Eastrall/orgs","repos_url":"https://api.github.com/users/Eastrall/repos","events_url":"https://api.github.com/users/Eastrall/events{/privacy}","received_events_url":"https://api.github.com/users/Eastrall/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-09-07T12:12:44Z","updated_at":"2016-09-09T14:30:33Z","closed_at":null,"body":"In the current implementation of the UWP version, when we want to change views we have to call:\r\n\r\n`NavigationService.Navigate(typeof(Views.Objects.AddObject));`\r\nhttps://github.com/jsthibault/Domo-Think-EIP/blob/App-WindowsPhone/Domo-Think-Windows/Domo-Think/ViewModels/Objects/ObjectsViewModel.cs#L127\r\n\r\nThe problem here is that we didn't respect the MVVM pattern because we have a view call inside our ViewModel.\r\n\r\nI'm currently working on a fix to separate the viewmodel and view logic."},"comment":{"url":"https://api.github.com/repos/jsthibault/Domo-Think-EIP/issues/comments/245930248","html_url":"https://github.com/jsthibault/Domo-Think-EIP/issues/1#issuecomment-245930248","issue_url":"https://api.github.com/repos/jsthibault/Domo-Think-EIP/issues/1","id":245930248,"user":{"login":"Eastrall","id":4021025,"avatar_url":"https://avatars.githubusercontent.com/u/4021025?v=3","gravatar_id":"","url":"https://api.github.com/users/Eastrall","html_url":"https://github.com/Eastrall","followers_url":"https://api.github.com/users/Eastrall/followers","following_url":"https://api.github.com/users/Eastrall/following{/other_user}","gists_url":"https://api.github.com/users/Eastrall/gists{/gist_id}","starred_url":"https://api.github.com/users/Eastrall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eastrall/subscriptions","organizations_url":"https://api.github.com/users/Eastrall/orgs","repos_url":"https://api.github.com/users/Eastrall/repos","events_url":"https://api.github.com/users/Eastrall/events{/privacy}","received_events_url":"https://api.github.com/users/Eastrall/received_events","type":"User","site_admin":false},"created_at":"2016-09-09T14:30:32Z","updated_at":"2016-09-09T14:30:32Z","body":"I've found a solution about this problem.\r\n\r\nI've created a `ViewFactory` which contains a `Dictionnary<Type, Type>` which represents the ViewModel type and the View type.\r\nAt the initialization of the app, I'm going to add all the ViewModel-View couples like:\r\n\r\n`ViewFactory.Register<MainViewModel, MainPage>();`\r\n\r\nIn my `NavigationService` when I call the `Navigate` method which will take a `TViewModel` as template parameter.\r\n\r\n`NavigationService.Navigate<MainViewModel>();`\r\n\r\nWhat the navigate method will do is, search inside the `ViewFactory` dictionnary the match with the type passed as template parameter:\r\n\r\n`Type _viewType = ViewFactory.Get(type);`\r\n`frame.Navigate(_viewType, parameter);`\r\n\r\nWith this method we can entirely separate the View from the ViewModel and then respect the MVVM pattern.\r\n\r\n@GuillaumeMunsch @wehrli I guess you may be interested by this method if you use the MVVM approach ;-)\r\n\r\nDon't hesitate to send me a message if you need more informations.\r\n\r\nThis issue will be closed with the next push."}}
{"actor":{"display_login":"Eastrall"}}