Column resizing in wpf datagrid

放肆的年华 提交于 2019-12-12 13:47:27

问题


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.

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.


回答1:


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}"


来源:https://stackoverflow.com/questions/5923966/column-resizing-in-wpf-datagrid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!