23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

FIGURE 4-10 A common data-binding scenario between a source data object and two target UI elements, involving<br />

two direct bindings and one binding with a conversion function.<br />

How these bindings actually behave at run time then depends on the particular direction of each<br />

binding, which can be one of the following:<br />

One-time: the value of the source property (possibly with conversion) is copied to the target<br />

property at some point, after which there is no further relationship. This is what you automatically do<br />

when passing variables to control constructors, for instance, or simply assigning target property values<br />

using source properties. What’s useful here is to have a declarative means to make such assignments<br />

directly in element attributes, as we’ll see.<br />

One-way: the target object listens for change events on bound source properties so that it can<br />

update itself with new values. This is typically used to update a UI element in response to underlying<br />

changes in the data. Changes within the target element (like a UI control), however, are not reflected<br />

back to the data itself (but can be sent elsewhere as with form submission, which could in turn update<br />

the data through another channel).<br />

168

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!