简体   繁体   中英

How to place a long Grid in a WPF Layout Container?

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.

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.

您应该将Datagrid放入ScrollViewer ,然后将ScrollViewer放入Grid单元。

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM