0

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.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
alansiqueira27
  • 8,129
  • 15
  • 67
  • 111
  • 1
    what is the grid itself inside of? – Dave C Nov 08 '11 at 21:39
  • Setting the first RowDefinition Height to "Star" - doesn't make much sense as it'll never fill the remaining space, "Star" is normally used for the very last row or the very last column. Normally, UpdtaeLayout isn't needed - after all it work asynchronously so you watch window won't display the right figures anyway. –  Nov 08 '11 at 21:42
  • the grid has a scrollviewer, a grid and other stuff that doesnt matter. Ive already tried putting 0.8* and 0.2* or anything similar. – alansiqueira27 Nov 08 '11 at 21:51

2 Answers2

2

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.

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
erikH
  • 2,286
  • 1
  • 17
  • 19
  • this kind didnt solve. But made me notice the mistake. My main container of the userControl was a stackpanel. When I changed it to Grid. It worked! :D ty – alansiqueira27 Nov 08 '11 at 22:30
0

Used MinHeight,MaxHeight

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

then adjust your Scrollviewer on screen resolution

Ghotekar Rahul
  • 322
  • 3
  • 10