What’s New In Silverlight 3 – Element Binding

In Silverlight 3 you can now use one User Interface element as the binding object for another. This can greatly simplify your code. For example, if you wish to display the value of a slider in a text box, there is no need to create a data object to mediate their connection; you can bind the text box directly to the slider:

   1: <Slider x:Name="sUnBound"

   2:     LargeChange="10"

   3:     Maximum="100"

   4:     SmallChange="1"

   5:     Value="50"

   6:     VerticalAlignment="Bottom" />


   8:  <TextBlock x:Name="valueFromElement"

   9:   Text="{Binding Value, Mode=OneWay, 

  10:        ElementName=sUnBound}" />


Putting this in a new application will create a slider and a TextBlock and will bind the latter to the former and no code-behind is required at all.

Much more on this in the Mini-tutorial on Element Binding.

Previous: Easier Easing    Next Multi-Select List Box

About Jesse Liberty

Jesse Liberty has three decades of experience writing and delivering software projects and is the author of 2 dozen books and a couple dozen Pluralsight & LinkedIn Learning courses. He was a Senior Technical Evangelist for Microsoft, a Distinguished Software Engineer for AT&T, a VP for Information Services for Citibank and a Software Architect for PBS. He is a Xamarin Certified Mobile Developer and a Xamarin MVP and a Microsoft MVP.
This entry was posted in z Silverlight Archives. Bookmark the permalink.