# Wednesday, July 15, 2009

Silverlight 2 offered nice possibilities around data binding.

But one useful feature was missing: the binding of a UI element property to a property of another UI element.

Fortunately, this is now possible with Silverlight 3.

The simplest example to build is the binding of the Text property of a TextBlock to the Value of a Slider:

In this sample, the user may vary the amount he wants to loan using a Slider. This amount is displayed in the TextBlock above the slider.

Here is the corresponding XAML:

 

<TextBlock Margin="0" TextWrapping="Wrap" Text="{Binding Value, ElementName=Amount, Mode=OneWay}" Foreground="White" FontFamily="Franklin Gothic Heavy" FontSize="32" HorizontalAlignment="Center" VerticalAlignment="Center"/>

 

<Slider ValueChanged="Amount_ValueChanged" Minimum="5000" Maximum="500000" x:Name="Amount" Cursor="Hand" SmallChange="5000" LargeChange="10000" Margin="0" Value="200000"/>

 

To see this application in action: http://www.renaldnollet.com/samples/HomeLoanSL3V0_1/

See you later!