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

前端 未结 2 776
心在旅途
心在旅途 2020-12-17 09:07

I have a ScrollViewer and in that I am showing the Vertical Scrollbar, Now on changing resolution of the system I want to get the width of the scrollbar. I went through One

2条回答
  •  星月不相逢
    2020-12-17 09:52

    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.

提交回复
热议问题