Friday, March 20, 2009

Silverlight 3 Beta ElementToElement Binding

Finally it is released with developer license and available for download here.

It has got so many features.Among them the Element to Element Binding got my attention first.That is the feature which I was waiting from the beginning as I came from WPF background.

What is Element to Element Binding

It is nothing but binding one element’s property to other element’s property.If the properties are of different type we need to employee a converter.

   1: <StackPanel>

   2:             <Slider x:Name="sldr" />

   3:             <TextBox Text="{Binding ElementName=sldr,Path=Value,Mode=TwoWay}"  />

   4:</StackPanel>



Here the Slider is the source and the TextBox is the destination.Whenever the Slider changes the TextBox will get slider’s value and vice versa.
If there is no mode specification the binding will be one way hence the TextBox will get updated as per Slider.But slider will not update as per TextBox.

No comments: