Silverlight Scroll Bars Control - Version 1 - RTLStandardScoll
Vertical Scrollbars for a canvas that contains a TextBlock. The scroll bar sizes itself and can be added with only 1 line of XAML.
While working on a recent Silverlight project I found it necessary to have scroll bars for some of our TextBlocks that had changing text lengths. I found a few options on the web but nothing that I wanted to implement on a consistent basis. What I really needed was a solution that would allow me to attach a set of Vertical Scroll Bars quickly and without the hassle of sizing or calculating scroll increments each time.
The solution I came up with was to create a custom control for Silverlight using managed code. The control requires only one line of XAML to use:
While working on a recent Silverlight project I found it necessary to have scroll bars for some of our TextBlocks that had changing text lengths. I found a few options on the web but nothing that I wanted to implement on a consistent basis. What I really needed was a solution that would allow me to attach a set of Vertical Scroll Bars quickly and without the hassle of sizing or calculating scroll increments each time.
The solution I came up with was to create a custom control for Silverlight using managed code. The control requires only one line of XAML to use:
<RTL:RTLStandardScroll_V1 x:Name="scBar" Canvas.Top="20" Canvas.Left="20" ButtonColor="#FFFFFF" GripColor="#111111" ArrowColor="#000000" TrackColor="#CCCCCC" ScrollObject="cvsTheText" />
The Canvas.Top, Canvas.Left properties are ignored (they are generated automatically by the control). The color properties let me set the colors quickly and the ScrollObject is the name of the TextBlock to scroll. The TextBlock but be contained inside of a Canvas. That Canvas should start with 2 children. The first is a Canvas.Clip and the second is the TextBlock.
That is all there is to it.
You can view a demo and download the source here: http://www.RealTimeSilverlight.com

The next version will include support for Horizontal scrolling.
Currently the colors must be set using a six-digit Hex value.
If you have any questions or suggestions for future versions feel free to contact me.