简体   繁体   English

如何在WPF布局容器中放置长网格?

[英]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. 当我将数据网格放置在WPF网格布局容器中时,数据网格会延长网格布局。 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. 确保您的Grid.ColumnDefinition或Grid.RowDefinition的Width或Height未设置为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. 网格放置在一个Tabitem中。 I tried the scrollviewer. 我试过了scrollviewer。 but the only thing that happens: the scrollviewer gets as large as the too long datagrid. 但是唯一发生的事情是:scrollviewer变得和太长的数据网格一样大。

as the tabitem can vary in height, I would rather not like to specify a fixed height for the grid. 由于Tabitem的高度可以变化,因此我不想为网格指定固定的高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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