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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With