Tech Off Post

Single Post Permalink

View Thread: Silverlight 4 : ItemSource vs DataContext
  • User profile image

    turrican said:
    spivonious said:

    I see. Thanks for the clear help.


    I do have " ItemsSource="{Binding}"" in my XAML for the listBox1.


    A small question, "myThingies"... in my case, it's a ObservableCollection<T>, now, how can I have "Stuff","Things","People" in this? Do you mean 3 other ObservableCollection<T> inside that one with the name "Stuff","Things" and "People"?


    and if that is the case, so when I do the  ItemsSource="{Binding Stuff}" , it will automatically match it with it, right?


    What I mean is, I do understand what you said but I am unsure how I can have several collections in "one" and then attach it to the datacontext? Could you give me a small sample code on an observablecollection having "3" stuff in it?



    The DataContext can be whatever you want it to be.  It doesn't have to be a collection. The property is available on all WPF controls.


    In one of my WPF apps, I have the DataContext set to an instance of a DataSet, and the bindings refer to the tables inside.