views:

62

answers:

3

When I place a Datagrid in a WPF Grid Layout container, the datagrid lengthens the Grid Layout. I want it to occupy only the space available on screen.

A: 

Make sure your Grid.ColumnDefinition or Grid.RowDefinition's Width or Height is not set to Auto. If you set it to a fixed size or a star size then the row/column should not resize.

If you're still having problems a code sample would be useful.

Groky
A: 

You should place your Datagrid into a ScrollViewer, and the ScrollViewer into your Grid cell.

Mart
If your TabItem gets large, then you have to look at its container. The TabItem takes all the space it can, so the parent container must be limited in size, which can be done in many ways without fixing them.Can you provide your XAML hierarchy so I can understand your structure?
Mart
A: 

the grid is placed inside a tabitem. I tried the scrollviewer. but the only thing that happens: the scrollviewer gets as large as the too long datagrid.

as the tabitem can vary in height, I would rather not like to specify a fixed height for the grid.

wpf