列大小调整在WPF数据网格 [英] Column resizing in wpf datagrid

查看:275
本文介绍了列大小调整在WPF数据网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在开发一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆