简体   繁体   中英

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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