列大小调整在WPF数据网格 [英] Column resizing in wpf datagrid
问题描述
我目前正在开发一个WPF软件。我使用WPF,我试图让列自动调整大小以适应使用DataGrid。
I am currently developing a WPF software. I am using WPF and am trying to allow the columns to auto size to fit in with the datagrid.
我已经使用columnWidth时=*,这很好,只要该窗口没有滚动视图内封闭运作。如果是在一个滚动视图,则该列调整非常大,导致了数据网格来调整引起大量的滚动屏幕更宽关闭的边缘。
I have used columnwidth="*" which works fine as long as the window is not enclosed within 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.
推荐答案
您可以尝试结合您的ScrollViewer的宽度
到 ActualWidth的
的DataGrid 的>。因此,在的ScrollViewer
把这个(假设你的网名为MyMainGrid):
You might try binding your scrollviewer's Width
to the ActualWidth
of the DataGrid
. So on the ScrollViewer
put this (assuming your grid is named MyMainGrid):
Width="{Binding ElementName=MyMainGrid, Path=ActualWidth}"
这篇关于列大小调整在WPF数据网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!