Hi
can any one tell me what is difference b/w DataContext property and itemsorce, source and where these use...........?
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Datta KharadRank #2,135 · 668 reputationPosted Nov 18, 2011, 3:16 AM EST
You can refer this link...
http://stackoverflow.com/questions/3169245/difference-between-itemssource-and-datacontext-as-pertains-to-listbox
http://www.sourcecode.mncinterview.com/2011/08/difference-between-datacontext-and.html
Satyapriya NayakRank #47 · 31.5K reputationPosted Nov 18, 2011, 6:03 AM EST
Please refer the below links.
http://www.c-sharpcorner.com/uploadfile/tirthacs/difference-between-datacontext-and-itemssource-in-wpfsilverlight/
http://jimzhou1985.blogspot.com/2009/05/what-is-difference-between-datacontext.html
Thanks
Priya LingeRank #785 · 2.9K reputationPosted Nov 20, 2011, 9:45 PM EST
1.DataContext property is exposed by FrameworkElement base class.
2.ItemsSource is defined by the ItemsControl class.
3.DataContext is of type Object.
4.ItemsSource property is of type IEnumerable.
5.DataContext is used to hold common data for other controls to bind.
we set the DataContext in a top-level parent element.
By doing this, many other child element can bind the appropriate value from
the data that top-level element holds.
DataContext does nothing for generating template.
6.ItemsSource property is use to generate template
Example >
7.DataContext is mainly used to hold common data that other child want to share.
Thus it can be inherited by other child elements without problem.
8.ItemsSource is not used to share data in the visual tree. It only valid for the element that defined.
9.Suppose ,we have several child elements that will share a common data source, we can set DataContext property for the parent elements.
10.we use ItemsSource for ItemsSource in most cased to generate template.
Example >
Hope this will help you.Thanks.