WPF 工具包 - 将数据网格高度调整为内容高度
我有一个 WPF 数据网格,希望它的高度等于其行 + 标题的高度之和。
即,如果我的数据网格标题为 100 像素,并且有 4 行,每行高度为 50 像素,则数据网格的总高度应为 300 像素。
有没有一种方法可以声明性地指定高度应与其内容的总和相匹配?
I have a WPF datagrid and would like it's height to equal the sum of the heights of it's rows + header.
i.e. if my datagrid header is 100px and I have 4 rows, each 50px in height the total height of my datagrid should be 300px.
Is there a way of declaratively specifying that the height should match the sum of it's contents?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
可以请您粘贴您的代码吗?因为您所要求的可以通过将 DataGrid 放入面板中来简单地实现,这不会限制其大小并将其精确地排列在控件的所需大小内。
换句话说,您可以将其以垂直方向放置在 StackPanel 中,就是这样:
Could you please paste your code? Because what you are asking can be simply achieved by placing DataGrid into a panel, which will not constrain its size and arrange it exactly within desired size of a control.
In other words, you can place it inside StackPanel with vertical orientation, and that's it: