Silverlight features three data binding modes. The first mode, the default mode, is one-way data binding. In one-way data binding data moves from the model to the view only. Changes made in the view, such as inside of a TextBox control, will not change the underlying property in the model.
Two-way data binding allows changes to propagate back to the model. Two-way data binding is perfect for editable forms, but you do need to explicitly set the two-way mode. An example is shown below.
<TextBox Margin="10" Text="{Binding Mode=TwoWay, Path=TotalHours}"/> <TextBlock Text="Start Date"/> <TextBox Margin="10" Text="{Binding Mode=TwoWay, Converter={StaticResource dateFormatter}, ConverterParameter='{0:d}', Path=PayPeriod.Start}"/>
The mode is the OneTime mode. When you use OneTime binding, Silverlight will move data from the model to the view element only once. Even if the model uses INotifyPropertyChanged and the underlying data changes, the changes will not be reflected in the UI.
No comments:
Post a Comment