2

I have a TextBlock and three Grids, contained inside another Grid. Each inner grid contains a TextBlock in the first row and DataGrid in the second. The data in the datagrids has a variable number of records.

<Grid Name="gridOuter">
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition Height="*" />  // <-- x3 
    ...
  </Grid.RowDefinitions>

  <TextBlock Grid.Row="0" Text="Contents" />

  <Grid Grid.Row="1" Name="innerOne" MinHeight="50" MaxHeight="???">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="*" />
    </Grid.RowDefinitions>

    <TextBlock Grid.Row="0">Heading One</TextBlock>
    <ScrollViewer Grid.Row="1">
      <DataGrid Name="dataGridOne">
        <DataGridColumns> 
          <DataGridTextColumn Header="Title" Binding="{Title}" /> 
          <DataGridTextColumn Header="Description" Binding="{Description}" /> 
        <DataGridColumns> 
      </DataGrid>
    </ScrollViewer>
  </Grid>
  ...
  <!-- x2 more with Grids named innerTwo and innerThree, with contained
       DataGrids named dataGridTwo and dataGridThree, respectively
  -->

</Grid>

I wish to set the MaxHeight of each of the inner grids to equal the ActualHeight of the outer grid, minus the sum of the MinHeights of the other two inner grids.

I'm using CalcBinding, but am open to any other solution.

I'm hoping I can do something like:

MaxHeight="{cb:Binding ActualHeight, ElementName=gridOuter
         - (cb:Binding MinHeight, ElementName=dataGridTwo 
           + cb:Binding MinHeight, ElementName=dataGridThree)}"

Is this possible with CalcBinding, and if so, what is the correct syntax - if not, is it possible some other way?

ASh
  • 34,632
  • 9
  • 60
  • 82
mcalex
  • 6,628
  • 5
  • 50
  • 80

0 Answers0