In MVVM, every View has a ViewModel. A View I understand to be a Window, Page or UserControl to which you can attach a ViewModel from which the view gets its data.
But a DataTemplate can also render a ViewModel's data.
So I understand a DataTemplate to be another "View", but there seem to be differences, e.g. Windows, Pages, and UserControls can define their own .dlls, one type is bound with DataContect the other through attaching a template so that Windows, Pages, UserControls can can be attached to ViewModels dynamically by a ServiceLocator/Container, etc.
How else are DataTemplates different than Windows/Pages/UserControls when it comes to rendering a ViewModel's data on the UI? And are there other types of "Views" other than these four?
The way I use it, the DataTemplate is actually the way to link the View to the ViewModel. Typically my DataTemplates in MVVM look like that :
<DataTemplate DataType="{x:Type vm:FooViewModel}">
<v:FooView />
</DataTemplate>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With