Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine the width of the vertical scroll bar in a ScrollViewer

I'm using a ScrollViewer to display an Image. The Image has a ScaleTransform set as one of it's LayoutTransforms. I've got it setup to fit the width of the image into the ActualSize of the ScrollViewer. My problem is that if the image height requires the vertical scrollbar to be present (I have it set to Auto) then my image is scaled just a little bit to much. I know how to determine if the scrollbar would be present and how to get the correct scale, but I cannot figure out how to determine what the actual width of the scrollbar is. I guess I could just guess at it, but I'd like something that would work if I later add styles to my application that would result in the scrollbars being a different size. Additionally I'm also doing Fit to Height and would need to get the Height of the horizontal scrollbar when it would be visible (I'm assuming that the answer to getting the width of the vertical scrollbar would make getting the height of the horizontal scrollbar obvious).

like image 686
juharr Avatar asked May 05 '10 23:05

juharr


1 Answers

You can use SystemParameters.ScrollWidth.

like image 173
Hans Passant Avatar answered Sep 28 '22 08:09

Hans Passant