我想要创建一个垂直(-90变换角度)的TextBlock
(或一些其他文本仅用于显示的元素),但我希望该元素填充它包含的垂直空间中,但有一个定义的水平量(我使用垂直和水平项而不是高度和宽度,因为当我将TextBlock
垂直移动时它会被交换),并将它对齐到容器的左侧。TextBlock填充垂直空间
我相信我明白如何使TextBlock
垂直使用RenderTransform
或LayoutTransform
。然而,我似乎无法让“对接”正常工作,只要我改变容器的垂直方向,水平方向而不是垂直方向增加。
以下是我有:在用户控件的
<UserControl
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
x:Class="AttendanceTracker.StudentView"
x:Name="UserControl" Height="172.666" Width="417.333">
<StackPanel x:Name="LayoutRoot" Orientation="Horizontal">
<Border BorderBrush="Black" BorderThickness="1" RenderTransformOrigin="0.5,0.5" Background="#52FFFFFF" Width="139.667">
<TextBlock Text="My Title" TextWrapping="Wrap" FontSize="18.667" TextAlignment="Center" Foreground="White" Margin="-58.509,68.068,49.158,70.734" Background="Black" RenderTransformOrigin="0.5,0.5" Width="147.017" d:LayoutOverrides="Height">
<TextBlock.RenderTransform>
<TransformGroup>
<ScaleTransform/>
<SkewTransform/>
<RotateTransform Angle="-90"/>
<TranslateTransform/>
</TransformGroup>
</TextBlock.RenderTransform>
</TextBlock>
</Border>
</StackPanel>
变化的高度,你会发现,TextBlock
增加水平方面,而不是所需的垂直方面。