简体   繁体   English

ScrollViewer 垂直滚动条预留空间

[英]ScrollViewer vertical scroll bar reserving space

In my scrollviewer, when there is no content to scroll vertically, as the visibility of the vertical scrollbar is set to "auto" it doesnt display.在我的滚动查看器中,当没有垂直滚动的内容时,由于垂直滚动条的可见性设置为“自动”,它不会显示。 However it still reserves say 20px space on the right of the scrollviewer.但是它仍然在滚动查看器的右侧保留了 20px 的空间。

Is there a way to make it release this space when there is no scrollbar visible?当没有滚动条可见时,有没有办法让它释放这个空间? Then my content would stretch to fit the space.然后我的内容会拉伸以适应空间。

What you describe should not happen, possibly some panel you use is restricting the layout, consider this simple example:您描述的情况不应该发生,可能您使用的某些面板限制了布局,请考虑以下简单示例:

<Window
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
      <Border  BorderThickness="1" BorderBrush="Red">
        <Button Width="200" Height="200" Content="!"/>
      </Border>
  </ScrollViewer>
</Window>

The red border is always at the edges, whether the scrollbars are there or not.无论滚动条是否存在,红色边框始终位于边缘。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM