确定ScrollViewer中垂直滚动条的宽度 [英] Determine the width of the vertical scroll bar in a ScrollViewer

查看:102
本文介绍了确定ScrollViewer中垂直滚动条的宽度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ScrollViewer来显示图像.Image的ScaleTransform设置为它的LayoutTransforms之一.我已经进行了设置,以使图像的宽度适合ScrollViewer的ActualSize.我的问题是,如果图像高度要求显示垂直滚动条(我将其设置为自动"),那么我的图像就会缩放几倍.我知道如何确定滚动条是否存在以及如何获得正确的比例,但是我无法弄清楚如何确定滚动条的实际宽度是多少.我想我只是可以猜出来,但是我希望如果以后在我的应用程序中添加样式,导致滚动条的大小不同时,某些东西会起作用.另外,我也在做适合高度",需要在可见时获得水平滚动条的高度(我假设,获得垂直滚动条宽度的答案将使得获得水平滚动条的高度显而易见).

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

推荐答案

您可以使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆