Binding a slider control to a textblock using databinding in Silverlight XAML

Declare slider:

<Slider x:Name="Myslider" Margin="3" 
 Minimum="1" Maximum="40" Value=" 10"> 
</Slider>

The binding is defined in the TextBlock element. Instead of setting the FontSize using a literal value, you use a binding expression, as shown here:

<TextBlock Margin=" 10" Text="Simple Text" x: Name="lblSampleText" FontSize=" {Binding ElementName=Myslider, Path=Value}" > 
</TextBlock>

When the slider is changed, its value will affect the font size of the textblock font.

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.