简体   繁体   English

列在wpf datagrid中调整大小

[英]Column resizing in wpf datagrid

I am currently developing a WPF software. 我目前正在开发WPF软件。 I am using WPF and am trying to allow the columns to auto size to fit in with the datagrid. 我正在使用WPF,我正在尝试允许列自动调整大小以适应数据网格。

I have used columnwidth="*" which works fine as long as the window is not enclosed within scrollview. 我使用了columnwidth =“*”,只要窗口未包含在scrollview中,它就能正常工作。 If it is in a scroll view then the columns resize really big which causes the datagrid to resize wider off the edge of the screen causing a large amount of scrolling. 如果它在滚动视图中,则列调整大小非常大,这会导致数据网格从屏幕边缘调整得更宽,从而导致大量滚动。

Thanks for any help you can provide. 感谢您的任何帮助,您可以提供。

You might try binding your scrollviewer's Width to the ActualWidth of the DataGrid . 您可以尝试将scrollviewer的Width绑定到DataGridActualWidth So on the ScrollViewer put this (assuming your grid is named MyMainGrid): 所以在ScrollViewer放这个(假设你的网格名为MyMainGrid):

Width="{Binding ElementName=MyMainGrid, Path=ActualWidth}"

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

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