如何通过保持自动调整大小功能来旋转 WPF 中的文本 [英] How to rotate Text in WPF by keeping the Auto-Sizing function
问题描述
我想要一个垂直的文本.我只是在 WPF 中使用一个简单的网格来自动调整区域大小.但是当使用 RotateTransform
时,所有的计算都是错误的.知道如何解决这个问题吗?
I want to have an text vertical. I just use a simple grid in WPF to auto-size the areas. But when using RotateTransform
, all calculations are wrong. Any idea how to solve this?
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
在这张图片中,你明白我的意思.如果我现在想自动调整中间部分的大小,我不能使用Width"或Height"属性,因为两者都会引发错误的大小调整结果.Width =120px 将增加水平(原始)宽度并使整行变为 120 像素.Height=120px 将使文本高度为 120 像素.
In this image you see what I mean. If I now want to auto-size the middle part I cannot use "Width" or "Height" property because both will raise a wrong sizing result. Width =120px will increase the horicontal (original) width and will make the complete row 120pixel. Height=120px will make the text 120pixel height.
推荐答案
使用 LayoutTransform
而不是 RenderTransform
.它在布局过程中应用,而不是在渲染过程中.
Use a LayoutTransform
instead of a RenderTransform
. It gets applied during the layout pass, not during rendering.
这篇关于如何通过保持自动调整大小功能来旋转 WPF 中的文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!