What is the differnce between DataTemplate and DataContext in WPF?
- by Ashish Ashu
I can set the relationship b/w View Model and view through following DataContext syntax:
<UserControl.DataContext>
<view_model:MainMenuModel />
</UserControl.DataContext>
And I can also set the relationship b/w View Model and view through following DataTemplate syntax:
<DataTemplate
DataType="{x:Type viewModel:UserViewModel}">
<view:UserView />
</DataTemplate>
Please let me know what is the difference between the two ? Is the second XAML does not set the data context of a view ?