This is the 11th article in the series, which describes data binding in Silverlight 2.
Data binding Mode
In Silverlight 2, data binding is supported in three modes.
1.OneTime: Bind once, use source data to update the target when binding is created, apply to display only data without updating data.
2.OneWay: One-way binding, updated to target when binding is created or when the source data changes, and applies to data that displays changes.
3.TwoWay: Bi-directional binding, you can update both the source data and the target at any time.
Jesse Liberty The example of a very image, using Silverlight to develop an online bookstore, showing the book title, author and other information, using the onetime mode, these data generally will not be changed; display price information using OneWay mode, Because the administrator may adjust the price in a single day; the number of books is displayed in TwoWay mode, with the quantity changing as the user's subscription changes, i.e. both the target and the source data are updated.
Simple Data binding
In this example we will do a simple data binding to display the user information, which is the following XAML:
<grid x:name= "LayoutRoot" background= "#46461F" >
<Grid.RowDefinitions>
<rowdefinition height= "160" ></RowDefinition>
<rowdefinition height= "></RowDefinition>"
<rowdefinition height= "></RowDefinition>"
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<columndefinition width= "></ColumnDefinition>"
<columndefinition width= "*" ></ColumnDefinition>
</Grid.ColumnDefinitions>
<image source= "terrylee.jpg" width= "height=" "100"
Horizontalalignment= "left" grid.row= "0" grid.column= "1"/>
<textblock foreground= "White" fontsize= "text=" Name: "
grid.row= "1" grid.column= "0" horizontalalignment= "right"/>
<textblock x:name= "Lblname" foreground= "White" fontsize= "18"
grid.row= "1" grid.column= "1" horizontalalignment= "left"/>
<textblock foreground= "White" fontsize= "text=" Location: "
grid.row= "2" grid.column= "0" horizontalalignment= "right"/>
<textblock x:name= "lbladdress" foreground= "White" fontsize= "18"
grid.row= "2" grid.column= "1" horizontalalignment= "left"/>
</Grid>