I have LandingPageViewModel
with GetHomework Button
. If I click on GetHomework Button
it takes to HomeworkPageViewModel
.
Now the problem is, where to call my service to get Homework data?
In LandingPageViewModel
s GetHomeworkExecute()
method and hold all Homework record in public accessible variable OR use NavigationParameter
to pass to the next page then use it in HomeworkPageViewModel
(or in other ViewModel
s if holding record in global variable).
OR
In HomeworkPageViewModel
s OnNavigatingTo()
(act as onload I think) method overridden by INavigatedAware
What is the good way to call the service when moving one ViewModel
to another?
I'd put it into HomeworkPageViewModel
, probably in the constructor (unless it's an async
call). Rationale: if the HomeworkPageViewModel
can do it (because it does not need additional info), then let it do it. Try not to spread out things, keep your code together.