views:

144

answers:

2

Hi there,

when creating a new ViewModel within the locator class using the snippet it creates a Cleanup Method but there is already one available from the Main so hence an error....

Should we merge them all??

Or should we be renaming the method to Cleanup[Name of viewmodel] for example.

I am a little confused here

Another question i would like to ask is regards to the naming conventions.

I tried to follow the naming convention used with "MAIN"...

hence i have CreateLogin, ClearLogin, Login (non static property for binding) etc etc..

Would it not be better to use CreateLoginViewModel, ClearLoginViewModel etc??

Just curious

Thanks

+2  A: 

Hi,

This snippet (and the ViewModelLocator in general) need work, and it is going to be a major change in V4.

Yes, the intent was to merge the Cleanup method generated by the snippet with the one already available. The idea is that you can just call ViewModelLocator.Cleanup() and have all the VMs clean themselves up (for example persisting their state to local storage, closing streams, etc...). Since a snippet cannot modify an existing method, I decided to just duplicate the Cleanup method. It won't compile, so the developer should know to merge them.

That said, it is not satisfactory to have a CreateMain, ClearMain etc for each VM type. I think we all agree that this is a weak implementation, and I want to improve it by providing a generic ViewModelLocator in the future (V4).

Regarding naming conventions, they are just conventions. I was tired to type "ViewModel", but feel free to use your own convention. As I said, the snippet will probably not be needed in V4 anymore. Apologies in the meantime for the inconvenience ;) (note that you can easily modify the snippet if you want to)

Cheers, Laurent

LBugnion
So I moved all my ClearVM statements into the single Cleanup method in ViewModelLocator, but then I noticed that when I exited my WP7 app it threw an error on the VM that I had not used. To fix this I wrapped the cleanup checks in an IsNull check, but I am worried that I am doing something wrong (I have a strange error where my messages are firing multiple times and I think it is related to Cleanup - http://stackoverflow.com/questions/4049387/mvvmlight-message-register-firing-multiple-times-in-wp7-cleanup-problem -thanks in advance for any insights!
Rodney
A: 

Thanks Laurent, i'm using you're framework. Love it <3

I was searching if i have to merge both cleanup method. Or delete cleanup snippet genereted method.

Bye ! Best regards