So far I have been implementing MVVM in my silverlight app pretty well, I just had one question. I have a few User Controls that I made and was wondering if they should be placed in the Views folder or in a seperate folder call UserControls. Is a user control considered a view?
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
So I would put the UserControls that are Views in your Views folder, while UserControls that are customized controls in your UserControl folders.
And personally, I wouldn't sort an MVVM application into Model, View, and ViewModel folders. It makes maintenance too obnoxious. Suppose you wanted to add a field to an item. You have to hunt down that item in all 3 folders to make the change. In larger applications, this is very annoying.
Instead I'd suggest grouping your objects based on their functionality. For example, I would place my CustomerView, CustomerViewModel, and CustomerModel all in a single folder called Customer.
In larger applications, I will separate the MVVM layers out into separate libraries, however the same concept still applies. The project that holds my data will store all Customer Models in a folder called Customer, my project holding my business logic will store all the Customer ViewModels in a folder called Customer, and my UI layer will store all Customer-related Views (UserControls and/or ResourceDictionaries w/ DataTemplates) in a single folder called Customer.