如何通过保留自动调整大小功能在 WPF 中旋转文本
我想要一个垂直的文本。我只是在 WPF 中使用一个简单的网格来自动调整区域大小。但是当使用RotateTransform
时,所有的计算都是错误的。知道如何解决这个问题吗?
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
在这张图片中你明白我的意思了。如果我现在想自动调整中间部分的大小,我不能使用“宽度”或“高度”属性,因为两者都会产生错误的大小调整结果。宽度 =120px 将增加水平(原始)宽度,并使整行为 120 像素。 Height=120px 将使文本高度为 120 像素。
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>
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用
LayoutTransform
而不是RenderTransform
。它在布局过程中应用,而不是在渲染过程中应用。Use a
LayoutTransform
instead of aRenderTransform
. It gets applied during the layout pass, not during rendering.就像 Rachel 说的,使用 LayoutTransform
Like Rachel said use LayoutTransform