我想要創建一個垂直(-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
增加水平方面,而不是所需的垂直方面。