开发者

WPF Datagrid column resizing upon changing FontSize

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 开发者_如何学JAVAare 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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜