Silverlight DataBinding Modes for the WPF Developer

I was suprised to find out that Silverlight Data Binding uses OneWay as the default binding mode. This really caught me off guard when I was trying to port some code written in WPF over to Silverlight since all of my TextBox.Text bindings did not have an entry for Mode in the binding statement. The reason of course is that by default TextBox.Text uses a Mode of TwoWay in WPF. In fact many of the common controls like TextBox.Text, ComboBox.Text, MenuItem.IsChecked, etc. have TwoWay as their default mode.

If you are writing code that will be used on both platforms I would suggest adding Mode to the binding statement. It’s a pain but it will save you the debugging hassle when your UI is not passing values back to the classes it is bound to.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>