Suppose we have an ItemsControl, which is bounded to a source.
Is there any performance difference between
ItemsControl.DataContext = resultSet;
and
ItemsControl.ItemsSource = resultSet;
(In both cases correctly binded in XAML)
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.
Well, a performance difference doesn’t really matter since the two lines do completely different things. The DataContext is the object that local databindings of the ItemsControl are taken from:
Will take the Length property of the object set as the DataContext and bind it to the Width dependency property of the ItemsControl.
On the other hand the ItemSource is the IEnumerable object that should be iterated to create the child items inside the control. (Each object inside the ItemSource will become the DataContext of the child item it created)