wpf - Why are DataContext and ItemsSource not redundant? -
In the WPF database, I understand that you have data contacts Which tells an element which is going to bind the data and ItemsSource that "binds"
But eg In this simple example, it does not appear that ITSource is anything useful because, you DataContext it Excluding
& lt; List box data contact = "{static resources customer}" item source = "{binding}" & gt; In more complex examples of and ItemsSource , you have a path and source that datacontax .
ItemSource = "{binding path = images, source = {static resource ISFFTDs}}" The best way to understand these two concepts What's the way to know when and how to apply in different coding scenarios?
datacontax to select the context of the binding of those cases An easy way is where a clear source is not specified. It is inherited, which makes it possible to do this:
& lt; StackPanel Datacontex = "{static resource data}" & gt; & Lt; List Box Itemsource = "{Binning Customers}" /> & Lt; List Box Itemsource = "{Binding Orders}" /> & Lt; / StackPanel & gt; In this case, you can: Here, there are a collection of resources on the customer and orders "data". You could:
& lt; List box itemsource = "{binding source = {static resources customer}}" /> Because no other control reference set is required.
Comments
Post a Comment