What is preferable?
dataGrid1.ItemsSource = data;
Or:
public MainWindow()
....
this.DataContext = data;
....
<DataGrid ItemsSource="{Binding}
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In my opinion that depends on the design you are using.
If you’re using the MVVM pattern there’s no doubt about it: You’ll always use your ViewModel as the DataContext of your View.
In cases where you just want to bind a list to a ItemsSource without using MVVM I would prefer your first case.