I was looking for best approach to set data context property. I found three ways
Assign data context on View (either on XAML or code behind).
As
I personally like this approach because it makes me have to write less code :). It basically uses an IValueConverter
to lookup which view to use whenever a wpf control needs to present a ViewModel
visually and the IValueConverter
sets the datacontext for you. It also shows you how to create a datatemplate that allows you to require WPF to utilize this converter by default, something like this: