SIGN UP MEMBER LOGIN:    
ARTICLE

Bind ScrollBarToTextBox and TextBoxToScrollBar in Silverlight

Posted by Raj Kumar Articles | Silverlight with C# August 30, 2010
Thisarticle is all about binding of scrollbar to textbox and textbox to scrollbar with small piece of code in silverlight.
Reader Level:
Download Files:
 

This blog is all about binding of scrollbar to textbox and textbox to scrollbar with small piece of code in silverlight.

Create a new project and drag and drop a scrollbar and a textbox on page. Let's start with ScrollBarToTextBox first.

<ScrollBar Height="138" HorizontalAlignment="Left" Margin="66,10,0,0" Maximum="100" LargeChange="10" Value="{Binding ElementName=textBox1, Path=Text}" Name="scrollBar1" VerticalAlignment="Top" Width="22" />
 
<TextBox Height="23" HorizontalAlignment="Left" Margin="101,48,0,0" Name="textBox1" VerticalAlignment="Top" Width="265" Text="50" />

Here scrollbar will move according to textbox text. like if i enter 50 in textbox then scroll bar should be like this:

Image1.jpg

Image1.

If I change TextBox value then result should be like this:

Image2.jpg

Image2.

Now TextBoxToScrollBar.

<Separator Height="3" HorizontalAlignment="Left" Margin="9,154,0,0" Name="separator1" VerticalAlignment="Top" Width="471" />
<
ScrollBar Height="100" HorizontalAlignment="Left" Margin="67,175,0,0" Name="scrollBar2" VerticalAlignment="Top" Width="18" Maximum="100" LargeChange="10" />

<TextBox Height="23" HorizontalAlignment="Left" Margin="105,179,0,0" Name="textBox2" VerticalAlignment="Top" Width="261" DataContext="{Binding ElementName=scrollBar2}" Text="{Binding Path=Value}" />

And compile the application.

Image3.jpg

Image3.

When you move scroll bar the textbox text should change.

Image4.jpg

Image4.
 

Login to add your contents and source code to this article
share this article :
post comment
 
Become a Sponsor
PREMIUM SPONSORS
  • ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications.
    The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
Team Foundation Server Hosting
Become a Sponsor