alansiqueira27
alansiqueira27

Reputation: 8506

Scrollviewer ActualHeight exceeds the screen resolution

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.

Upvotes: 0

Views: 927

Answers (2)

Ghotekar Rahul
Ghotekar Rahul

Reputation: 342

Used MinHeight,MaxHeight

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

then adjust your Scrollviewer on screen resolution

Upvotes: 0

erikH
erikH

Reputation: 2346

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.

Upvotes: 2

Related Questions