I have a Grid of 5 rows. At row 2 and 4 I have a DataGrid. The other rows have a fixed Height. The contents of the tables in the DataGrids is of course dynamically determined, and therefore their height too. As in my particular app there is a relation between the height of the two tables, I want to adjust the MaxHeight of both at run-time. If a table is longer than the initially speficied MaxHeight, it is supposed to get a ScrollBar. But the Height of both Tables should never be longer than the browser's page.
Now I tried to do this at runtime triggered at some event:
if (availableSpace - heightOfTable1 - heightOfTable2 < 0)
{
if (heightOfTable1 > heightOfTable2)
{
Table1.MaxHeight = availableSpace - heightOfTable2;
// Trigger a rerendering
Table1.ItemsSource = null;
Table1.ItemsSource = List1;
...
}
...
}
However I noticed that the ActualHeight is not changed when I do this. The ActualHeight is now bigger than the specified MaxHeight at run time What am I doing wrong?