Determine the width of the vertical scroll bar in a ScrollViewer

Posted by juharr on Stack Overflow See other posts from Stack Overflow or by juharr
Published on 2010-05-05T23:10:08Z Indexed on 2010/05/06 0:28 UTC
Read the original article Hit count: 579

Filed under:
|
|

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).

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf