ScrollBar.ViewportSize Property

Definition

Gets or sets the amount of the scrollable content that is currently visible.

C#
public double ViewportSize { get; set; }

Property Value

The amount of the scrollable content that is currently visible. The default is 0.

Examples

The following example shows how to set the ViewportSize on a ScrollBar control.

C#
myScrollBarViewport.ViewportSize = 10;
XAML
<ScrollBar Name="myScrollBarViewport" Orientation="Horizontal" ViewportSize="10"/>

Remarks

The units that are used for ViewportSize are the same units that are used to describe the length of the content. Some examples include lines of text or pages of text.

The value of the ViewportSize property is used to calculate the size of the Thumb control that is displayed as the sliding value indicator in a ScrollBar control. The Thumb control's size represents the amount of a ScrollViewer control's content that is visible. If 25 percent of a ScrollViewer control's content is visible, the Thumb occupies 25 percent of the track in the ScrollBar.

You can decide which units ViewportSize uses. When you set this property, make sure that the ViewportSize, Minimum, Maximum, and Value properties use the same units.

The following illustration shows how the Thumb size reflects the amount of content that is visible.

The track length and thumbsize of a ScrollBar

Dependency Property Information

Item Value
Identifier field ViewportSizeProperty
Metadata properties set to true None

Applies to

Produkt Verzie
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10