I just want to ask if it's OK to access the ViewModel's
data in the View
backend?
Basically I just need a check to see if a ViewModel's
property is set (which gets set when the user selects something), and if it's not I'll just redirect the user to another View
telling him he needs to select something first. Is this a poor-design practice or is it OK, just for a minor check like this? Really don't want to implement a static class and extrapolate the data to it, and check it instead.
Another question tightly related to this, is can I call a method from the View
(when the View
is closing), that unregisters that particular ViewModel
from the IoC container (this ViewModel
isn't singleton). The alternative is to send a message from the View to the ViewModel
when the View
is closing, and when the ViewModel
gets that message it unregisters itself. The problem I'm trying to solve with this is that, every time that ViewModel
is requested it has to be a new one, but my IoC container caches them, making my program a memory hog. All of the ViewModels
get released on application exit, meaning x ViewModels
will still exist in the cache even though they're most likely not needed.