WPF Datagrid 列在更改 FontSize 时调整大小

发布于 2024-11-28 08:01:12 字数 404 浏览 2 评论 0原文

我在调整 DataGrid 大小时遇到​​了意外问题。

情况如下:我的应用程序要求之一是用户可以随时更改我的所有 DataGridFontSize。因此,网格应该相应更新。

我的列全部定义为自动调整大小。问题是:当我增加 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叶落知秋 2024-12-05 08:01:12

嗯...我还没有处理你遇到的具体问题。但我遇到了类似的问题以及 相应的解决方案 我想出了。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文