Introduction to WPF ScrollBar Control
The ScrollBar element of XAML is used to create a WPF ScrollBar control at design-time. The ScrollBar class in C# represents a ScrollBar control in code. This article and code samples demo how to use a scroll bar in a Window app.
- <ScrollBar></ScrollBar>
The Width and Height properties represent the width and the height of a ScrollBar. The Name property represents the name of the control, which is a unique identifier of a control. The Margin property tells the location of a ScrollBar on the parent control.
The Orientation property sets the direction of scrolling that can be either horizontal or vertical.
The following code snippet sets the name, height, width, orientation, margin, and background of a ScrollBar control.
- <ScrollBar Name="McScroller" Orientation="Horizontal"
- Width ="250" Height="30"
- Margin="10,10,0,0"
- Background="LightSalmon" />
The ScrollBar looks like Figure 1.

Setting up ScrollBar Value
The Value property of ScrollBar sets up the current value of a ScrollBar control. The Minimum and Maximum properties represent minimum and maximum range of a ScrollBar. In the following code, I set the Value property to 50 and now ScrollBar looks like Figure 2.
- <ScrollBar Name="McScroller" Orientation="Horizontal"
- Margin="10,10,0,0"
- Width ="250" Height="30"
- Background="LightSalmon"
- Minimum="1" Maximum="240"
- Value="50"/>


Join the conversation! Your thoughts help the community grow.