Reputation: 36205
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.
Upvotes: 4
Views: 1710
Reputation: 2944
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}"
Upvotes: 3