2009-08-26 11 views
2

垂直(-90の変換角度)のTextBlock(または表示用にテキストを含む他の要素)を作成したいが、その要素が含まれている垂直スペースを埋めるようにしたい(私は、TextBlockを垂直にしたときにスワップされているので、高さと幅の代わりに縦と横の用語を使用しています)、それをコンテナの左側に揃えます。TextBlockの縦のスペースを埋める

RenderTransformまたはLayoutTransformを使用してTextBlockを垂直にする方法を理解していると思います。しかし、私はコンテナの垂直面を変更するときはいつでも、「ドッキング」が正しく機能するように見えることはできませんTextBlock垂直の代わりに水平な面が増えます。ユーザーコントロールの

<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増加:ここ

は私が持っているものです。

答えて

6

私が正しくあなたを理解していれば、これは正しい方向にあなたを指している必要があります:

<StackPanel Orientation="Horizontal"> 
    <TextBlock Background="Red" Text="My Title"> 
     <TextBlock.LayoutTransform> 
      <TransformGroup> 
       <RotateTransform Angle="90"/> 
      </TransformGroup> 
     </TextBlock.LayoutTransform> 
    </TextBlock> 
</StackPanel> 

キーがLayoutTransform、ないRenderTransformを使用することです。これにより、変換が行われた後に別のレイアウトパスが確実に発生します。それ以外の場合、レイアウトシステムは元の境界矩形を使用してTextBlockをレイアウトしています。

それ以外では、Blendによって生成されたすべてのクラフトを取り除いて、何が起こっているのかを確認しました。結果は次のとおりです。

alt text http://img187.imageshack.us/img187/1189/screenshottbv.png

関連する問題