data-win-bind property

Expand
Language: JavaScript and HTML | VB/C#/C++ and XAML
1 out of 2 rated this helpful - Rate this topic

data-win-bind property

[This documentation is preliminary and is subject to change.]

Applies to: Metro style apps only

Binds a property of an element to a property of a data source.

Syntax



    <element data-win-bind="elementProperty1 : dataSourceProperty1; elementProperty2: dataSourceProperty2" />

Property value

Type: String

A string with the following format:

elementPropertyName : dataSourcePropertyName

where elementPropertyName is the name of a property on the host element, and dataSourcePropertyName is the name of a property of the data source. When the Template is used, the data source's property value is used to set the element's property.

Separate multiple sets of element/data source property pairs with a semicolon.

Examples

For more information about using this attribute, see the topic Quickstart: binding data and styles to HTML elements and the Declarative Binding sample.

For an example showing how to use an item template with a ListView, see the Add a ListView quickstart.

Requirements

Minimum supported client

Windows 8 Release Preview

Minimum supported server

Windows Server 2012

Library

Base.js

See also

Template
Quickstart: add a ListView

 

 

Build date: 5/22/2012

Did you find this helpful?
(1500 characters remaining)
Community Additions ADD
Binding to data-win-controls
<p>In order to bind a data-win-control (any control in the namespace WinJS.UI) prefix the property name with "winControl".</p><p>Example:</p><p><div data-win-control="WinJS.UI.ToggleSwitch" data-win-bind="winControl.checked: srcProperty"></div></p><p>I've found this information in the following thread:</p><p><mtps:InstrumentedLink NavigateUrl="http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/ccfae9bc-fde1-4d16-b2e8-cef237683c48" runat="server" xmlns:mtps="http://msdn2.microsoft.com/mtps">http://social.msdn.microsoft.com/Forums/en-US/winappswithhtml5/thread/ccfae9bc-fde1-4d16-b2e8-cef237683c48</mtps:InstrumentedLink></p>
5/24/2012
Use of Template is not required
The article might give the impression that data-win-bind can be used only inside a Template, but it's not true, one can add bindings without a Template as well. Just remember to call WinJS.Binding.processAll() properly.
3/27/2012
multiple binding sets
I think using a comma doesn't work. I got multiple bindings to work with a semicolon instead. With a comma, it just hangs.
12/8/2011