Files
docs-desktop/dotnet-desktop-guide/framework/wpf/controls/how-to-customize-the-thumb-size-on-a-scrollbar.md
Pooja Poojari a606313314 US-1889327: Header fixes (#1319)
* Metadata updates for US-1889327.

* H2 edits.

* Updated column header.

* Minor edits.

* Review edits.
2022-02-28 08:53:24 -08:00

2.3 KiB

title, description, ms.date, ms.custom, helpviewer_keywords, ms.assetid
title description ms.date ms.custom helpviewer_keywords ms.assetid
How to: Customize the Thumb Size on a ScrollBar Learn how to customize the Thumb Size on a ScrollBar. 03/30/2017 devdivchpfy22
ScrollBar control [WPF]
customizing thumb size [WPF]
thumb size [WPF]
fa32b866-5ca1-4e73-85e7-2ac64b80d194

How to: Customize the Thumb Size on a ScrollBar

This topic explains how to set the xref:System.Windows.Controls.Primitives.Thumb of a xref:System.Windows.Controls.Primitives.ScrollBar to a fixed size and how to specify a minimum size for the xref:System.Windows.Controls.Primitives.Thumb of a xref:System.Windows.Controls.Primitives.ScrollBar.

Create a ScrollBar with a fixed Thumb size

The following example creates a xref:System.Windows.Controls.Primitives.ScrollBar that has a xref:System.Windows.Controls.Primitives.Thumb with a fixed size. The example sets the xref:System.Windows.Controls.Primitives.Track.ViewportSize%2A property of the xref:System.Windows.Controls.Primitives.Thumb to xref:System.Double.NaN and sets the height of the xref:System.Windows.Controls.Primitives.Thumb. To create a horizontal xref:System.Windows.Controls.Primitives.ScrollBar with a xref:System.Windows.Controls.Primitives.Thumb that has a fixed width, set the width of the xref:System.Windows.Controls.Primitives.Thumb.

[!code-xamlScrollBarCustomThumbSize#1]

Create a ScrollBar with a minimum Thumb size

The following example creates a xref:System.Windows.Controls.Primitives.ScrollBar that has a xref:System.Windows.Controls.Primitives.Thumb with a minimum size. The example sets the value of xref:System.Windows.SystemParameters.VerticalScrollBarButtonHeightKey%2A. To create a horizontal xref:System.Windows.Controls.Primitives.ScrollBar with a xref:System.Windows.Controls.Primitives.Thumb that has a minimum width, set the xref:System.Windows.SystemParameters.HorizontalScrollBarButtonWidthKey%2A.

[!code-xamlScrollBarCustomThumbSize#2]

See also