Scrollviewer ActualHeight exceeds the screen resolution

937 views Asked by At

I have a Grid with these rows settings: (I can't post much code, sorry)

RowDefinition Height="1*"

RowDefinition Height="120"

Inside that grid I have a ScrollViewer with Height="Auto" and verticalAlignment = "Stretch" at Row 0.

At row 2 I have another grid with a fix height of 60 pixels.

When I do this.UpdateLayout (inside an UserControl), then the scrollviewer.ActualHeight goes to 2332, which is the same size of an image inside it and exceed the resolution screen. Why its not updating to fit the screen?

Thanks.

2

There are 2 answers

1
erikH On BEST ANSWER

If you place the outer Grid in f.i. a StackPanel with orientation vertical, then there might not be a limit on the height of the grid, and then not a vertical limit on the ScrollViewer. Place the Grid in a DockPanel, or set a (maximum) height of the Grid. Then the ScrollViewer will have a limited height.

0
Ghotekar Rahul On

Used MinHeight,MaxHeight

<ScrollViewer 
            VerticalAlignment="Top"
            Grid.Column ="0"    
            MinHeight="60"
            MaxHeight="190"
            Grid.Row="0"
            />

then adjust your Scrollviewer on screen resolution