Windows apps
Collapse the table of content
Expand the table of content
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.ViewportSize Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

Namespace:   System.Windows.Controls.Primitives
Assembly:  PresentationFramework (in PresentationFramework.dll)

public double ViewportSize { get; set; }

Property Value

Type: System.Double

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

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

Identifier field

ViewportSizeProperty

Metadata properties set to true

None

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

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

.NET Framework
Available since 3.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show:
© 2018 Microsoft