0
votes

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.

1

1 Answers

2
votes

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.