Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ScrollBar Class

Represents a control that provides a scroll bar that has a sliding Thumb whose position corresponds to a value.

Namespace: System.Windows.Controls.Primitives
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

[LocalizabilityAttribute(LocalizationCategory.NeverLocalize)] 
[TemplatePartAttribute(Name="PART_Track", Type=typeof(Track))] 
public class ScrollBar : RangeBase
/** @attribute LocalizabilityAttribute(LocalizationCategory.NeverLocalize) */ 
/** @attribute TemplatePartAttribute(Name="PART_Track", Type=System.Windows.Controls.Primitives.Track) */ 
public class ScrollBar extends RangeBase
LocalizabilityAttribute(LocalizationCategory.NeverLocalize) 
TemplatePartAttribute(Name="PART_Track", Type=System.Windows.Controls.Primitives.Track) 
public class ScrollBar extends RangeBase
<ScrollBar .../>

The following illustration shows a ScrollBar control.

Scrollbar illustration

The ScrollBar control contains a Track control. The Track control consists of a Thumb control and two RepeatButton controls. You can increase and decrease the Value property of the ScrollBar control by pressing the RepeatButton controls or by moving the Thumb. The default range of values for the Value property is from 0 to 1. The Value represents the linear distance of the Thumb between the endpoints of the ScrollBar. You can change the default range of values by setting the Minimum and Maximum properties. The Orientation property determines whether the ScrollBar is displayed horizontally or vertically, and you must define this property for the ScrollBar control to appear.

The Track in a ScrollBar is oriented so that values increase from top to bottom for a vertical ScrollBar or from left to right for a horizontal ScrollBar.

The Track properties in the following table are the binding targets for the corresponding ScrollBar properties when the Track property is not explicitly defined. If you explicitly define the Track property, the binding does not occur.

Track Property

ScrollBar Property

Track.Maximum

RangeBase.Maximum

Track.Minimum

RangeBase.Minimum

Track.Value

RangeBase.Value

Track.Maximum

RangeBase.Maximum

Track.Minimum

RangeBase.Minimum

You can access the Track control of a ScrollBar control by using the Track property.

To display UIElement content inside a box that has scrollbars, use the ScrollViewer control.

The following example shows how to create a horizontal ScrollBar that has a range of values between 0 and 100.

<ScrollBar Orientation="Horizontal" Width ="4in"
           Scroll="OnScroll" Minimum="1" Maximum="100" />

More Code

How to: Create a ScrollBar

This example shows how to create a ScrollBar.

System.Object
   System.Windows.Threading.DispatcherObject
     System.Windows.DependencyObject
       System.Windows.Media.Visual
         System.Windows.UIElement
           System.Windows.FrameworkElement
             System.Windows.Controls.Control
               System.Windows.Controls.Primitives.RangeBase
                System.Windows.Controls.Primitives.ScrollBar

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

Show:
© 2014 Microsoft