This documentation is archived and is not being maintained.

ScrollBar.ViewportSize Property

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

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

public double ViewportSize { get; set; }
/** @property */
public double get_ViewportSize ()

/** @property */
public void set_ViewportSize (double value)

public function get ViewportSize () : double

public function set ViewportSize (value : double)

<object ViewportSize="double" .../>

Property Value

The amount of the scrollable content that is currently visible. The default value is zero (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 has a minimum size that is defined by the operating system. The size of a Thumb control becomes larger as more content is visible. The size of a Thumb control represents the amount of content that is visible. For example, if 25 percent of a Thumb control's content is visible, the control occupies 25 percent of the track in which it moves.

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

ScrollBar thumbSize

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

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

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