0

I've a WPF application with a main grid with 4 rows. I wont to bind the property MaxHeight of the row(0) by XAML or code behind to the Height value of the control inside. The control inside row(0) is a ScrollViewer and at run time, I add controls inside the SV.

I've tried with the XAML code:

<Grid Name="MainGrid">
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" MinHeight="64" MaxHeight="{Binding Path=ActualHeight, ElementName=HeaderScrollViewer}"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
        <RowDefinition Height="50"/>
 </Grid.RowDefinitions>

And by code behind :

  Grid.SetRow(Me.MainGrid, 0)
  Me.MainGrid.MaxHeight = Me.HeaderScrollViewer.Height
  Me.MainGrid.UpdateLayout()

But no luck...any suggestions?

Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Jotric
  • 49
  • 1
  • 1
  • 6
  • so u basically want the height of the first row only to be controlled dynamically? – JackyBoi Mar 12 '12 at 14:51
  • http://stackoverflow.com/questions/147908/how-do-i-databind-a-columndefinitions-width-or-rowdefinitions-height – Phil Mar 14 '12 at 07:37

1 Answers1

0

Try it with ActualHeight.

  Grid.SetRow(Me.MainGrid, 0)
  Me.MainGrid.MaxHeight = Me.HeaderScrollViewer.ActualHeight <---
  Me.MainGrid.UpdateLayout()
Dave Clemmer
  • 3,741
  • 12
  • 49
  • 72
Gepro
  • 583
  • 1
  • 11
  • 20
  • When I add controls, the grid.row(0).Heigth is setted to "Auto", then the ScrollView I have inside row(0) can expand. At the end of adding operations I have the dimensione of the control. But I can't set the MaxHeigt correctly.In any case, with Heigth property the graphic result is better and I don't know why. – Jotric Mar 13 '12 at 07:13