gpt4 book ai didi

wpf - 如何将旋转的 TextBlock 锚定到顶部?

转载 作者:行者123 更新时间:2023-12-04 05:50:37 25 4
gpt4 key购买 nike

使用以下代码,文本 ABCDE 从网格顶部开始,并将字母放在网格之外。

我怎样才能使文本保持在网格内并且最后一个字母在网格的顶部结束?

<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<TextBlock Text="ABCDE" >
<TextBlock.RenderTransform>
<RotateTransform Angle="-90" />
</TextBlock.RenderTransform>
</TextBlock>
</Grid>
</Window>

最佳答案

使用 LayoutTransform而不是 RenderTransformLayoutTransform在布局过程中应用,而不是渲染过程

<TextBlock Text="ABCDE"  >
<TextBlock.LayoutTransform>
<RotateTransform Angle="-90" />
</TextBlock.LayoutTransform>
</TextBlock>

关于wpf - 如何将旋转的 TextBlock 锚定到顶部?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10094145/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com