Windows store scrollviewer control vertical height doesn't return to original size when switching between portrait and landscape

StackOverflow https://stackoverflow.com/questions/23376992

  •  12-07-2023
  •  | 
  •  

Question

The problem is that when I switch to portrait mode, everything extend down to fill the available space like it should, but when I rotate back, the controls don't go back to the position they started from, they remain in positions that are out of view in landscape mode.

Anyone know how to fix this?

I'm using the simulator to test the rotation.

EDIT I confirmed its the ScrollViewer fault, I enabled the vertical scrollbar and verified that when I rotate to portrait the ScrollViewer vertical size extends in height to accommodate the portrait mode, then when I rotate back, the ScrollViewer maintains its height and all the controls inside it got displaced as a result.

    <ScrollViewer Grid.Row="1" Margin="0,-140,0,0"  VerticalScrollMode="Disabled" VerticalScrollBarVisibility="Hidden" HorizontalScrollMode="Enabled" HorizontalScrollBarVisibility="Visible">
    <Grid Margin="0,-140,0,0" Grid.Row="1"  ></Grid>>
    </ScrollViewer>

when I replace the Scrollviewer with a Grid the effect disappears and the controls resize correctly when I switch between portrait and landscape

Was it helpful?

Solution

I think I found the answer but I hope someone can verify, seems to work in the simulator.

I removed the issue by setting both of these values to disabled. It wasn't enough to just set one to disabled and the other to hidden, they both have to be disabled

VerticalScrollMode="Disabled" 
VerticalScrollBarVisibility="Disabled"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top