Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find Vertical Scrollbar width of a Scrollviewer in C#

People also ask

How do you find the width of a scrollbar?

To get the width of the scrollbar, you use the offsetWidth and clientWidth of the Element : The offsetWidth returns the width of the Element in pixels including the scrollbar. The clientWidth returns the with of the Element in pixels without the scrollbar.

What is the scrollbar width?

The scrollbar-width property is used to set the width or thickness of an element's scrollbar when shown. This property can be used on pages where the user interface requires the element to be displayed more prominently and shrinking the scrollbar width gives more space to the element.

Does width include scrollbar?

The window. innerWidth is the actual width of the window, including scrollbars, but not including the window border.


I think SystemParameters.VerticalScrollBarWidth is what you are looking for.


I am not sure if this is the correct answer. Every WPF control can be restyled so even the scrollbar. So SystemParameters.VerticalScrollBarWidth works only if it is used as default scrollbar. The correct solution would be to find the vertical scrollbar in the visual tree and measure it's ActualWidth. It is the most precise measurement.