WPF Datagrid 列在更改 FontSize 时调整大小
我在调整 DataGrid
大小时遇到了意外问题。
情况如下:我的应用程序要求之一是用户可以随时更改我的所有 DataGrid
的 FontSize
。因此,网格应该相应更新。
我的列全部定义为自动调整大小。问题是:当我增加 FontSize
时,DataGrids
会正确调整大小。 但是,当我减小 FontSize
时,所有行都会适当调整大小,但列标题仅保持当前大小!
我想说在这种情况下自动调整大小方法很奇怪,我的意思是,为什么它不应该像调整行那样调整列的大小?
仅供参考,我正在 .NET 3.5 和 .NET 3.5 下工作。 WPFToolkit 的数据网格。
I am having an unexpected issue with DataGrid
resizing.
Here is the situation: one of my application requirements is that users can change all my DataGrid
's FontSize
on-the-go. The grid should therefore be updated accordingly.
My columns are all defined to Auto-resize. The problem is: when I increase the FontSize
, the DataGrids
are correctly resized.
However, when I decrease FontSize
, all rows resize appropriately, but the column headers just keep their current size!
I'd say that the auto-resizing method is strange in this case, I mean, why shouldn't it juste resize the column like it did with the rows?
FYI, I'm working under .NET 3.5 & WPFToolkit's DataGrid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
嗯...我还没有处理你遇到的具体问题。但我遇到了类似的问题以及 相应的解决方案 我想出了。
DataGrid 非常擅长在需要时增加列大小……但在减少列大小方面却遇到了困难。我很惊讶行会正确缩小...(我猜测字体大小变化的原因会导致重新计算)。但我猜测要获取列标题,您将必须按照上面提供的链接中的建议手动强制布局刷新。
希望上述方法也适用于您的具体问题。或者至少也许你从中发现了一些有用的东西。
Hmmm... I haven't dealt with the specific issue you're having. But there was a similar problem I ran into and the corresponding solution I came up with.
The DataGrid is great at increasing its column sizes when needed... but struggles with decreasing them. I'm surprised that the rows shrink correctly for you... (I'm guessing something with the font size changing causes a re-calculation). But I'm guessing to get the column-headers you're going to have to manually force an layout refresh as suggested in the link provided above.
Hopefully, the approach above will also work for your specific problem. Or at least maybe you find something useful from that.