I am little new and I have a doubt in relation with databinding.
To bind something I usually use {binding propertyName,...}
but in some post/blogs I can see the kind of code like ItemsSource="{Binding}"
. Why not use ItemsSource="{Binding YourCollection}"
?
W开发者_JS百科hat are the differences?
Thank you! :=)
Some times the current DataContext
is the collection that supplies the items for some ItemsControl like a ListBox
. In which case there is no property to bind to, the source object as a whole is the value to be assigned to the ItemsSource
property. That's what ItemsSource="{Binding}"
means. When no property path is specified the binding's Source
object is passed in.
Whereas ItemsSource="{Binding YourCollection}"
means find the property called YourCollection
on the Source
object and pass its value to ItemsSource
.
精彩评论