Showing posts with the label knockout.js

Knockout.js binding syntax bind to root, self, current context

When using knockout.js if your ViewModel is an array and you want to bind to the entire ViewModel, the syntax to bind to the ViewModel root, when the root is the current context:

<ul data-bind="foreach: $data"> <li> <p data-bind="text: SomeTextProperty"> </p> </li> </ul>

The XAML syntax equivalent when the DataContext is an array:

<itemscontrol ItemsSource="{Binding Path=.}"> ... </itemscontrol>

Hope this helps,