Duplizieren von:Differenz betwwen Datacontext und ItemSource in WPF
Why are DataContext and ItemsSource not redundant?
In WPF wir Liste der Artikel zu ComboBox auf 2 Arten
//CODE #1
//WPF
<ComboBox name="cmbItems" ItemSource={Binding} />
//C#
cmbItems.DataContext = someList;
eine andere Art und Weise zuordnen können, direkt zuordnen itemsource
//CODE #2
//WPF
<ComboBox name="cmbItems" ItemSource={Binding} />
//C#
cmbItems. ItemSource = someList;
beide dienen dem Zweck, aber was ist der Unterschied in oben genannten Schnipsel? und was ist gut zu benutzen?
mögliches Duplikat von [Wer hat die beste Antwort dafür, warum DataContext und ItemsSource nicht redundant sind?] (Http://stackoverflow.com/questions/793340/who-has-the-best-answer-for-why- datacontext-and-itemssource-sind-nicht-redundant –