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

时光怂恿深爱的人放手 提交于 2019-11-30 07:49:51

问题


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 StackOverflow Post there they mention to check for SystemParameters.ScrollWidth Property but again I din find any help from their. Can anybody please help me to fix my issue. Any answer will be appreciated.


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/5701760/how-to-find-vertical-scrollbar-width-of-a-scrollviewer-in-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!