Reputation: 585
If the code-behind for the View
is meant to consist of nothing but the constructor with the InitializeComponent()
call, why not just use DataContext="{Binding RelativeSource={RelativeSource Self}}"
and use the view itself as a view model?
I get that this technically violates the Single Responsibility Principle, but since the XAML and code-behind are defined independently from each other, it doesn't cause the usual mess. Having separate view models for everything causes more mess to the file structure.
Upvotes: 2
Views: 914
Reputation: 3195
ViewModel describes view state. For testing and reusing purposes it must be UI independent. Benefits:
Upvotes: 5