MVVM - Controls versus Views

design-patterns, mvvm, silverlight, viewmodel, wpf

Solution

A `UserControl` in WPF is little more than a `ContentControl` with a few tweaked default property values. A `ContentControl` is little more than a piece of content that can have a template applied to define its look.

The way I do MVVM skips the middleman and defines views as `DataTemplate`s. Then you need only stick your VM into WPF's visual tree somewhere, and WPF will render it with your `DataTemplate`. For example:

<ContentControl Content="{Binding SomeViewModel}"/>

<ItemsControl ItemsSource="{Binding SomeViewModels}"/>

Problem

I've been doing a prototype in WPF without using MVVM. It's got to such a size now that I'm refactoring it to use MVVM. When I started the project, I jumped straight in and created UserControls for lots of things. I'm now breaking things in Views and ViewModels. But, I'm ending up with Views that contain UserControls; the UserControls have bindings to what are now objects in the Model. So, is the notion of UserControls now dead in MVVM? What I mean is, in the past (WinForms, ASP.NET etc.) you'd have a project called 'Controls' and reuse these. Is the 'View' in MVVM a direct replacement of the typical UserControl?

Original source