Binding one GUI element to another

This very simple example binds the size of a TextBlock element's text to a slider. A two way binding from a textbox's Text property to the slider allows you to enter a number to set the size of text. Three lines of code accomplish this in xaml:

 <Slider Name="sliderFontSize" Margin="3,3,56,283" Minimum="6" Maximum="72" Value="12" TickFrequency="1" TickPlacement="TopLeft" />
 <TextBlock Margin="10,30,10,156" Text="Hello World!" Name="lblSampleText" FontSize="{Binding ElementName=sliderFontSize, Path=Value}" />
 <TextBox Name="lblSize" Text="{Binding ElementName=sliderFontSize, Path=Value}" Margin="0,3,0,287" HorizontalAlignment="Right" Width="50" />

ProgrammingLinks/BindingToAnElement (last edited 2011-12-10 00:53:29 by 71-87-243-206)