Let's say I have a LoginView and its data context, LoginViewModel, needs to be injected with a service that can authenticate a user based on their username/password.
Now let's say that the state of the application is that someone has already logged in, but now they are logging out and I need to redisplay the login screen for the next user. So at this point I need an instance of my LoginViewModel but I'm not sure how to go about getting it.
Should I be injecting a LoginViewModel into my ShellViewModel and holding onto it and reusing it? That seems odd because why would I want to keep that in memory while I'm not using it (granted, not a big deal in this case but could be for other cases).
Should I be injecting the authentication service into ShellViewModel to hold onto for whenever it needs to create a LoginViewModel? That seems odd because my ShellViewModel doesn't need to do anything with this service and if this were the answer then I'd be injecting all kinds of stuff into my ShellViewModel for all the other ViewModels it displays.
And I know I'm not supposed to be referencing my DI container anywhere other than the root of my application or I'll be implementing a Service Locator pattern.
Admittedly, I'm feeling pretty dumb right now and I'm sure I'm going to slap myself in the face when I hear the answer... so what is it?