1

I have a DataGrid with RowDetailsTemplate that contains a DataGrid. The parent grid is placed in it's own row. The row is defined as

<RowDefinition Height="*" />

Usually this means the row will take the REST of the available hight and initialy it does. But if the DataGrid is too large for the space left on the screen, the buttom of the DataGird disaperas "under the screen" instead of getting a scrollbar.

I have tried to solve it by defining MaxHeight=400 for parent grid but even than, the parent grid is unlimited in it's length and still gets so long that it's buttom part is invisible.

Any ideas what to do about it?

Keren
  • 81
  • 2
  • 10

2 Answers2

0

I think you should not use a StackPanel. If Orientation is Vertical, its height grows to infinity. maybe you should use another Panel.

Also see this link: ScrollViewer not scrolling in WPF

Community
  • 1
  • 1
Ramin
  • 2,133
  • 14
  • 22
  • Thank you for your answer. I replaced the Stackpanel with a grid (so everything in the stackpanel was on top of each other, just to see if it can solve the provblem) and unfortunately I got the exact same bad behavior so this doesn't solve the problem. – Keren Dec 19 '12 at 09:03
  • My initiale question was about a grid with a stackpanel init but I took away everything and is only left with a datagrid inside a datagrid and still have the same problem so I changed the question to that. – Keren Dec 19 '12 at 09:29
  • @Keren, I upped your question maybe others help you. But I suggest to write more details. In fact it is a bit unclear. – Ramin Dec 19 '12 at 09:34
  • As I am testing here I am getting more or more to the buttom of it. What I found out now is that even if I write "MaxHeight = 400", the grid will still ignore it and be as long as it wants (as in auto) which means the lower part of it is invisible. – Keren Dec 19 '12 at 09:48
0

Setting MaxHight to the parent grid has no effect what so ever on the grid's height. On the other hand, Setting a MaxHight to the inner grid does work.

Therefore I solved like this: First I took my row and named it "rowGridRow".

Than I subscribed on the Loaded event of the inner grid and did this:

    private void dgGroupMedlem_Loaded(object sender, RoutedEventArgs e)
    {
        DataGrid dgGroupMedlem = sender as DataGrid;
        dgGroupMedlem.MaxHeight = rowGridRow.ActualHeight - xxx;
    }

xxx is some value that compensates for the other things around (like headers) and should likely be calculated based on the number of rows that the parent grid have.

Keren
  • 81
  • 2
  • 10